Witam.
Ogarniam Home Assistant’a i Node RED’a już od kilku dni. Czas najwyższy spytać na forum bo moje rozwiązania są zazwyczaj dosyć skomplikowane. Był już jeden podobny temat na forum ale bez szczegółów, dlatego chcę dopytać.
Otóż chcę za pomocą jednego przycisku (oferuje pojedyncze, podwójne, potrójne itp. przyciśnięcie) zmienić kolor żarówki. Wiem, że muszę odczytać stan aktualnego koloru za pomocą “current state” ale nie wiem jak to zrobić. Załączam swój kod, który do tej pory zrobiłem. Uprzedzam, że nie jestem jakoś bardzo obeznany z fachową terminologią więc trzeba tłumaczyć jak dziecku
Ktoś ma jakiś pomysł? Wiem jak reagować na dany “current state” ale nie wiem jak poprawnie ustawić warunek, który ma odczytać wartość atrybutu “rgb_color”.
[{"id":"118dabded9d09c9b","type":"server-state-changed","z":"77d7482ee14af714","name":"Przycisk","server":"596fc9d0.d3e778","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.s1_click","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":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":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":80,"y":300,"wires":[["650fdb65c7ccc850"]]},{"id":"650fdb65c7ccc850","type":"switch","z":"77d7482ee14af714","name":"Rodzaj naciśnięcia?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"single","vt":"str"},{"t":"eq","v":"double","vt":"str"},{"t":"eq","v":"triple","vt":"str"},{"t":"eq","v":"quadruple","vt":"str"},{"t":"eq","v":"many","vt":"str"},{"t":"eq","v":"long","vt":"str"},{"t":"eq","v":"long_release","vt":"str"}],"checkall":"true","repair":false,"outputs":7,"x":280,"y":300,"wires":[["3d479135799e3d6f"],["eb4222ec2b25ca1b"],[],[],[],[],[]]},{"id":"eb4222ec2b25ca1b","type":"api-current-state","z":"77d7482ee14af714","name":"Obecny kolor?","server":"596fc9d0.d3e778","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.o4","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":500,"y":280,"wires":[["078ecb0af33c0d45"]]},{"id":"078ecb0af33c0d45","type":"switch","z":"77d7482ee14af714","name":"Zmiana loloru","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"\"[255,255,255]\"","vt":"str"},{"t":"eq","v":"\"[0,255,255]\"","vt":"str"},{"t":"eq","v":"\"[255,255,0]\"","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":700,"y":280,"wires":[["bb5edd7d648ab3be"],["102a8e45d1dbe8e3"],["b2046b4856e73f74"]]},{"id":"bb5edd7d648ab3be","type":"api-call-service","z":"77d7482ee14af714","name":"Kolor 1","server":"596fc9d0.d3e778","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.o4","data":"{\"rgb_color\":\"[0,255,255]\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":880,"y":240,"wires":[[]]},{"id":"3d479135799e3d6f","type":"api-call-service","z":"77d7482ee14af714","name":"Włącz - biały","server":"596fc9d0.d3e778","version":3,"debugenabled":false,"service_domain":"light","service":"toggle","entityId":"light.o4","data":"{\"rgb_color\":[255,255,255]}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":490,"y":220,"wires":[[]]},{"id":"102a8e45d1dbe8e3","type":"api-call-service","z":"77d7482ee14af714","name":"Kolor 2","server":"596fc9d0.d3e778","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.o4","data":"{\"rgb_color\":\"[255,255,0]\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":880,"y":280,"wires":[[]]},{"id":"b2046b4856e73f74","type":"api-call-service","z":"77d7482ee14af714","name":"Kolor 3","server":"596fc9d0.d3e778","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.o4","data":"{\"rgb_color\":\"[255,255,255]\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":880,"y":320,"wires":[[]]},{"id":"596fc9d0.d3e778","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]