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…
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
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.
Why I need it, I want send alert messages to telegram only when I’m away.
OpenAPI: iHost User Guides-API - SONOFF Official
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
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.
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.
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?
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.