UNPKG

node-red-contrib-home-assistant-websocket

Version:
1 lines 3.77 kB
[{"id":"c14460fdc14a24a0","type":"group","z":"1cc7d2e94a4815fe","name":"Sensor node - set state and attribute values","style":{"label":true,"color":"#000000"},"nodes":["ba71e67aa0d06f02","4c7a952705afe4a0","e06208fe5410cfb5","23dfef724e706db3","a6d8e76c9ca8af97","fbbda709b5a50be7"],"x":214,"y":219,"w":912,"h":222},{"id":"ba71e67aa0d06f02","type":"inject","z":"1cc7d2e94a4815fe","g":"c14460fdc14a24a0","name":"Manual Trigger","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":340,"y":260,"wires":[["4c7a952705afe4a0"]]},{"id":"4c7a952705afe4a0","type":"ha-sensor","z":"1cc7d2e94a4815fe","g":"c14460fdc14a24a0","name":"How many lights are on","entityConfig":"02814df043c7111b","version":0,"state":"$entities().*[state = \"on\" and entity_id ~> /^light|^switch/] ~> $count()","stateType":"jsonata","attributes":[{"property":"lights_table","value":"$entities().*[state = \"on\" and entity_id ~> /^light|^switch/].{\"name\": attributes.friendly_name, \"lastChange\": last_changed}","valueType":"jsonata"},{"property":"time","value":"","valueType":"date"}],"inputOverride":"allow","outputProperties":[],"x":610,"y":260,"wires":[[]],"server":""},{"id":"e06208fe5410cfb5","type":"server-state-changed","z":"1cc7d2e94a4815fe","g":"c14460fdc14a24a0","name":"","server":"","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"sensor.lights_on_count","entityIdType":"exact","outputInitially":false,"stateType":"num","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"table","propertyType":"msg","value":"$entity().attributes.lights_table","valueType":"jsonata"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"changes","propertyType":"msg","value":"(\t $old:=$prevEntity().attributes.lights_table;\t $new:=$entity().attributes.lights_table;\t {\"on\": $new[$not(name in $old.name)],\t \"off\": $old[$not(name in $new.name)]}\t)","valueType":"jsonata"}],"x":630,"y":340,"wires":[["23dfef724e706db3","a6d8e76c9ca8af97","fbbda709b5a50be7"]]},{"id":"23dfef724e706db3","type":"debug","z":"1cc7d2e94a4815fe","g":"c14460fdc14a24a0","name":"Count of lights on","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":990,"y":280,"wires":[]},{"id":"a6d8e76c9ca8af97","type":"debug","z":"1cc7d2e94a4815fe","g":"c14460fdc14a24a0","name":"Array table","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"table","targetType":"msg","statusVal":"payload","statusType":"auto","x":970,"y":340,"wires":[]},{"id":"fbbda709b5a50be7","type":"debug","z":"1cc7d2e94a4815fe","g":"c14460fdc14a24a0","name":"Changes","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"changes","targetType":"msg","statusVal":"changes","statusType":"auto","x":960,"y":400,"wires":[]},{"id":"02814df043c7111b","type":"ha-entity-config","server":"","deviceConfig":"","name":"SC LS On Count","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"LS On Count"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false}]