-
In my flow, I need to dynamically identify and apply the state of a particular When I use the Flow using `binary_sensor` node``` [{"id":"33b41a57d83e295b","type":"ha-binary-sensor","z":"76a254bc7d454b53","name":"","entityConfig":"6333ce26e0a2603f","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1860,"y":140,"wires":[[]]},{"id":"ea84ab109ed6a714","type":"inject","z":"76a254bc7d454b53","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":1690,"y":100,"wires":[["33b41a57d83e295b"]]},{"id":"3d743cfb29ce2193","type":"inject","z":"76a254bc7d454b53","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":1690,"y":160,"wires":[["33b41a57d83e295b"]]},{"id":"6333ce26e0a2603f","type":"ha-entity-config","server":"61a9dd3f.9dc614","deviceConfig":"3eef4c6f50c4ec4f","name":"Fire - Fire Alarm System - Communication Failure","version":6,"entityType":"binary_sensor","haConfig":[{"property":"name","value":"Fire - Fire Alarm System - Communication Failure"},{"property":"icon","value":"mdi:wifi-off"},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":"connectivity"}],"resend":false,"debugEnabled":false},{"id":"61a9dd3f.9dc614","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false},{"id":"3eef4c6f50c4ec4f","type":"ha-device-config","name":"Rahal","hwVersion":"","manufacturer":"Transformaritime","model":"","swVersion":""}] ```then the states are set like this: and (the sensor in question is has a However, if I manually build a payload to set the state to (boolean) Flow using `API` node``` [{"id":"10b6da01d0dfc187","type":"ha-api","z":"76a254bc7d454b53","name":"Set Alarm State","server":"61a9dd3f.9dc614","version":1,"debugenabled":false,"protocol":"http","method":"post","path":"","data":"","dataType":"json","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":2100,"y":260,"wires":[[]]},{"id":"cfb98498c6b4effb","type":"function","z":"76a254bc7d454b53","name":"Build API payload","func":"msg.payload = {\n \"path\": \"/api/states/binary_sensor.fire_fire_alarm_system_communication_failure\",\n \"data\": {\n \"state\": msg.payload\n }\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1890,"y":260,"wires":[["10b6da01d0dfc187"]]},{"id":"e53c6bb36648ab29","type":"inject","z":"76a254bc7d454b53","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":1690,"y":220,"wires":[["cfb98498c6b4effb"]]},{"id":"9f8164feb8223458","type":"inject","z":"76a254bc7d454b53","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":1690,"y":300,"wires":[["cfb98498c6b4effb"]]},{"id":"61a9dd3f.9dc614","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false}] ```Then the state gets set to and So... what does the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I haven't tested it but when updating the state of an entity via the REST API, you need to include the attributes in the payload; otherwise, it might overwrite the existing attributes with a blank set. To verify this, you can:
|
Beta Was this translation helpful? Give feedback.
-
That seems like it. In the screenshot below, I'm doing a simple So it seems the attributes are being overwritten by the Something like:
|
Beta Was this translation helpful? Give feedback.
I haven't tested it but when updating the state of an entity via the REST API, you need to include the attributes in the payload; otherwise, it might overwrite the existing attributes with a blank set.
To verify this, you can: