Change state of entity in HA using NodeRed

I have some switches that I control using the command_line switch component i HA. These switches are 433Mhz and are controlled over http GET. I have no issues controlling these switches, problem is that I have some physical switches that also control these lights, so when I use them, the status displayed in HA is wrong.

To just keep sending the turn_on/off command doesn´t feel like clean solution. Is there a way I can use Node Red to simly update the state of the switch?
I found this, but haven´t had any success getting it to work.

If there is no way to simply update a state i HA, then I would be happy to know how I can send the turn_on/off command only when checked state has changed from last check

Hello jappish 84, Although I am not a great expert, but I know that 433 mhz sockets have no return channel, the current switching status of the socket can not be requested. Unfortunately, I do not see any solution to your problem. If the devices are connected to the network, you could use the “ping” node to see if the device is on or off, and then change the switch setting to HA with “Call Service”.

Thanks for the reply! I have a separate webserver that actually controls the 433 switches, and I can check the status of the switches either by using a python script I created, or the node red flow setup visible in the first post. Problem is, I don’t know how to change the status in HA without actually sending a switch on/off command. How can I only update the status in HA?

I had a similar problem umd I know that you can change the switching position of a switch in HA in the “dev tools” in “States” without an actual circuit is performed.

I had recently addressed my problem and Pippyn helped me a lot, but this will probably not solve your problem, but here is still the link to my problem. Can you have a look …

https://community.home-assistant.io/t/developer-tools-states/95815/18

See post # 30 in the thread linked below. It explains how to change the state using Nodered. It involves installing the node-red-contrib-hass package which contains a hass-post node. Might be worth trying though there’s discussion about whether the api still allows this.

3 Likes

Ah very interesting, thanks for the information, I’ll look at the “Node” in any case …

Awesome, that’s just what I was looking for! Thank you very much!

1 Like

hmm, damn it. Seems addon doesn’t communicate to the new HA Auth system :confused:

msg : string[85]
"hass-post: API call http://localhost:8123/api/states/swich.xbox_power, statusCode 401"
2019-02-03 23:53:19node: set state
msg : string[24]
"common.errors.nooverride"
2019-02-03 23:53:19node: edf8005e.7dbd4
msg.payload : string[54]
"{"state": "off","attributes": {"assumed_state": true}}"
2019-02-03 23:53:19node: set state
msg : string[85]

You need the websocket version. I had this problem, now it can communicate… not sure if it has the post to HA piece or not, but it can communicate with the long lived tokens.

I’m sorry, I don’t quite follow what you are referring to :roll_eyes:

Could you be a bit more specific please?

Thanks

Use this version.

Awesome, thank you, will test this

Sorry, hadn’t had the time to test this until now. Unfortunately I can’t get this to work, I simply don’t understand what data I need to send to HA. I can successfully check the state of the switch, but what node should I use and what data do I send to HA?

I tried using the “Fire Event”-Node with the following data:

Event:

payload.data

Data:

{"entityid": "switch.xbox_power", "state": "on", "attributes": {"assumed_state": true}}

but nothing happens in HA, switch stays “off” even though server reports on.

EDIT:
Or if someone knows of a way to setup a node that only fires once on same message and ignores future messages until message has changed, I’d be interested in that aswell

EDIT2:
Managed to get around this by using the “rbe” node

Hi, I have Sonoff 4CH Pro 433Mhz with tasmota-knx. Update the state off my knx_light in HA from MQTT with one call service node.


3 Likes

Hey there!

I’m quite the beginner here, but:
I want to change the state if my Aqara vibration sensor to “off” after X seconds of being triggered and still can’t seem to find how to do that exactly.

Any suggestions?

For people who are not that familiar with NodeRed, APIs, “GET”, REST, “POST” commands, I suggest checking the “Set State” HACS approach shared on the links below. For me, this is by far the most straightforward approach.

https://community.home-assistant.io/t/set-state-without-calling-service/429307/6

Direct Github page:
https://github.com/xannor/hass_py_set_state