# How to get current security mode of iHost using node red?

**URL:** <https://forum.ewelink.cc/t/how-to-get-current-security-mode-of-ihost-using-node-red/26021>\
**Category:** eWeLink CUBE\
**Created:** [December 20, 2023, 9:43am UTC](https://forum.ewelink.cc/t/how-to-get-current-security-mode-of-ihost-using-node-red/26021 "2023-12-20T09:43:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![guillaume.ae](https://avatars.discourse-cdn.com/v4/letter/g/f14d63/32.png) [@guillaume.ae](https://forum.ewelink.cc/u/guillaume.ae)\
**Post date:** [December 20, 2023, 9:43am UTC](https://forum.ewelink.cc/t/how-to-get-current-security-mode-of-ihost-using-node-red/26021/1 "2023-12-20T09:43:17Z")

</div>

Hi all,

I would like to get the current security mode of my iHost device, in node red.  
I currently found out how to get an event on mode change using the “event state” node, but I can’t find a way to fetch on demand the current state.

I would like for example, when an HTTP request is triggered, to check the mode and send it back.

I also checked the open API but it does not seem to be there…

Any idea how to do this ?

Bests !

---

<div class="post-metadata">

**Author:** ![Teki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/teki/32/1161_2.png) [@Teki](https://forum.ewelink.cc/u/Teki)\
**Post date:** [December 21, 2023, 9:01am UTC](https://forum.ewelink.cc/t/how-to-get-current-security-mode-of-ihost-using-node-red/26021/2 "2023-12-21T09:01:11Z")

</div>

open API supports this, while the node-red palette does not.  
may I know why do you need this?  
you can create a flow like when the security mode changes, send a customized email to your mailbox.  
about the email part, refer to this video: [https://youtu.be/jdSg6ig84dE?si=c\_IyNtns7UgroXpH](https://youtu.be/jdSg6ig84dE?si=c_IyNtns7UgroXpH)

---

<div class="post-metadata">

**Author:** ![guillaume.ae](https://avatars.discourse-cdn.com/v4/letter/g/f14d63/32.png) [@guillaume.ae](https://forum.ewelink.cc/u/guillaume.ae)\
**Post date:** [December 21, 2023, 9:35am UTC](https://forum.ewelink.cc/t/how-to-get-current-security-mode-of-ihost-using-node-red/26021/3 "2023-12-21T09:35:18Z")

</div>

Hello @Teki , thanks for your reply.

I’d like to be able to check what is the current security mode.  
Let say I have a user that opens a web page, and in that web page I want to display the security status. To do this I need to be able to “get” the status, not wait for a status change.

How to do this using the open API ? I could not find reference to this.

Thanks again

---

<div class="post-metadata">

**Author:** ![lev.lybin](https://avatars.discourse-cdn.com/v4/letter/l/7feea3/32.png) [@lev.lybin](https://forum.ewelink.cc/u/lev.lybin)\
**Post date:** [January 20, 2024, 1:15pm UTC](https://forum.ewelink.cc/t/how-to-get-current-security-mode-of-ihost-using-node-red/26021/4 "2024-01-20T13:15:57Z")

</div>

Why I need it, I want send alert messages to telegram only when I’m away.  
OpenAPI: [iHost User Guides-API - SONOFF Official](https://sonoff.tech/ihost-user-guides/api/)  
Sorry, but I can’t to find it in API.

I’ve tried to solve it using event-state iHost arm/disarm + global env, but if restart iHost or power outage happened I not receive the current state.  
I’d like to get state of iHost using get-devices, using API is also okay but I’ve not found in documentation it.

and there are a bug, how to reproduce:

- arm iHost on any kind security
- the arming light is on on a device
- restart iHost
- the state is restored correctly
- but the arming light is off. expected: the arming light should be on
- pressing on the arming button turn on the arming light, the state of arming no changed

---

<div class="post-metadata">

**Author:** ![eerke](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@eerke](https://forum.ewelink.cc/u/eerke)\
**Post date:** [January 22, 2024, 7:37am UTC](https://forum.ewelink.cc/t/how-to-get-current-security-mode-of-ihost-using-node-red/26021/5 "2024-01-22T07:37:42Z")

</div>

You need a saved version of the state in Node Red itself rather than check it.  
Eg. With a change node SET global.AlarmState to “home” etc  
But that will be stored by default in memory and so vanish if there is a power cut. If you wish to save to file you need to edit the config file and to do that you need to install the file manager docker. Google “node Red context storage” and have a look here for the instructions about installing a file manager.  
It’s really easy but a pain in the neck.

---

<div class="post-metadata">

**Author:** ![lev.lybin](https://avatars.discourse-cdn.com/v4/letter/l/7feea3/32.png) [@lev.lybin](https://forum.ewelink.cc/u/lev.lybin)\
**Post date:** [January 22, 2024, 8:29pm UTC](https://forum.ewelink.cc/t/how-to-get-current-security-mode-of-ihost-using-node-red/26021/6 "2024-01-22T20:29:26Z")

</div>

Thanks, store the state in filesystem is better than memory, but “it caches the values in memory and only writes them out to the file-system every 30 seconds.” if a power cut happens within 30 seconds after state was changed, the state will be unsynced.

[https://nodered.org/docs/user-guide/context](https://nodered.org/docs/user-guide/context)

P.S. I bought this thing with the hope that I wouldn’t have to play with a wand.

---

<div class="post-metadata">

**Author:** ![eerke](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@eerke](https://forum.ewelink.cc/u/eerke)\
**Post date:** [January 22, 2024, 8:51pm UTC](https://forum.ewelink.cc/t/how-to-get-current-security-mode-of-ihost-using-node-red/26021/7 "2024-01-22T20:51:34Z")

</div>

You can change that value. It’s an inherent balance between not wanting to write to the disk too often and risking loosing data, but it’s up to you.  
I think the option is called flushInterval. It’s up to you how often you want the data saved to file. I think the default of 30s is pretty reasonable. The auto save feature on Microsoft Word is also adjustable. It’s impossible not to have on any of today’s computers. Try naming a single auto save in the world where this is not the case?

---

<div class="post-metadata">

**Author:** ![lev.lybin](https://avatars.discourse-cdn.com/v4/letter/l/7feea3/32.png) [@lev.lybin](https://forum.ewelink.cc/u/lev.lybin)\
**Post date:** [January 22, 2024, 9:57pm UTC](https://forum.ewelink.cc/t/how-to-get-current-security-mode-of-ihost-using-node-red/26021/8 "2024-01-22T21:57:54Z")

</div>

Home security and ms word are not comparable. flushInterval=0 is crazy, 30sec by default have a risk to lost so important state.  
Also keep the second state is not so reliable, there is a risk desynchronization. Here is better probably to use write and read file. On change a state write to file, when it needed read it from this file.  
I will hope it will be provided in get-devices or in OpenAPI.  
I bought this thing for experiment, could I use for my needs or not. Currently nope.  
In any case, thank you for trying to help.

---

<div class="post-metadata">

**Author:** ![eerke](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@eerke](https://forum.ewelink.cc/u/eerke)\
**Post date:** [January 22, 2024, 11:17pm UTC](https://forum.ewelink.cc/t/how-to-get-current-security-mode-of-ihost-using-node-red/26021/9 "2024-01-22T23:17:33Z")

</div>

Numbers do exist between 0 and 30.
