Como evitar loop nessa automação via nodered

como posso evitar loop nessa automação?

como o comando para ligar e desligar é o mesmo botão acaba por ficar em loop

‘’‘[{“id”:“8071bec8c9fb0ae7”,“type”:“server-state-changed”,“z”:“e17ca6c3b32a21f8”,“g”:“3043ee2142704218”,“name”:“luz ventilador”,“server”:“40f09d9e1117eda5”,“version”:5,“outputs”:2,“exposeAsEntityConfig”:“”,“entityId”:“input_boolean.ligar_luz_do_ventilador”,“entityIdType”:“exact”,“outputInitially”:false,“stateType”:“str”,“ifState”:“on”,“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”:“data”,“propertyType”:“msg”,“value”:“”,“valueType”:“eventData”},{“property”:“topic”,“propertyType”:“msg”,“value”:“”,“valueType”:“triggerId”}],“x”:110,“y”:1740,“wires”:[[“a27e8117ce8f89ce”],[“86535eee4297842f”]]},{“id”:“a27e8117ce8f89ce”,“type”:“api-call-service”,“z”:“e17ca6c3b32a21f8”,“g”:“3043ee2142704218”,“name”:“”,“server”:“40f09d9e1117eda5”,“version”:5,“debugenabled”:false,“domain”:“remote”,“service”:“send_command”,“areaId”:,“deviceId”:[“19d0ef5734295e8a3121a65937f7db70”],“entityId”:[“remote.broadlink_rm4_pro”],“data”:“{\t "device": "ventilador sala",\t"command": "ligar luz"\t}”,“dataType”:“jsonata”,“mergeContext”:“”,“mustacheAltTags”:false,“outputProperties”:,“queue”:“none”,“x”:1110,“y”:1720,“wires”:[]},{“id”:“86535eee4297842f”,“type”:“alexa-remote-routine”,“z”:“e17ca6c3b32a21f8”,“g”:“3043ee2142704218”,“name”:“”,“account”:“5c9f2c63485dd599”,“routineNode”:{“type”:“smarthome”,“payload”:{“entity”:“8894b0d7-bc2b-4ab3-8b2b-30f389848d62”,“action”:“sceneActivate”}},“x”:1100,“y”:1760,“wires”:[]},{“id”:“8bc4fe242848a141”,“type”:“switch”,“z”:“e17ca6c3b32a21f8”,“g”:“3043ee2142704218”,“name”:“Check power”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“btwn”,“v”:“2”,“vt”:“num”,“v2”:“12”,“v2t”:“num”},{“t”:“eq”,“v”:“0”,“vt”:“num”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:470,“y”:1860,“wires”:[[“00f39eaa26163bdd”],[“a3ed689aa390fb1f”]]},{“id”:“00f39eaa26163bdd”,“type”:“api-call-service”,“z”:“e17ca6c3b32a21f8”,“g”:“3043ee2142704218”,“name”:“> 1 watt → define botão para ligado”,“server”:“40f09d9e1117eda5”,“version”:5,“debugenabled”:false,“domain”:“input_boolean”,“service”:“turn_on”,“areaId”:,“deviceId”:,“entityId”:[“input_boolean.ligar_luz_do_ventilador”],“data”:“”,“dataType”:“json”,“mergeContext”:“”,“mustacheAltTags”:false,“outputProperties”:,“queue”:“none”,“x”:1170,“y”:1840,“wires”:[]},{“id”:“823ce53833db5345”,“type”:“server-state-changed”,“z”:“e17ca6c3b32a21f8”,“g”:“3043ee2142704218”,“name”:“medidor de consumo do ventilador”,“server”:“40f09d9e1117eda5”,“version”:5,“outputs”:1,“exposeAsEntityConfig”:“”,“entityId”:“sensor.interruptor_do_ventilador_da_sala_potencia”,“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”}],“x”:180,“y”:1860,“wires”:[[“8bc4fe242848a141”]]},{“id”:“a3ed689aa390fb1f”,“type”:“api-call-service”,“z”:“e17ca6c3b32a21f8”,“g”:“3043ee2142704218”,“name”:“</= 0 watt → define botão para desligado”,“server”:“40f09d9e1117eda5”,“version”:5,“debugenabled”:false,“domain”:“input_boolean”,“service”:“turn_off”,“areaId”:,“deviceId”:,“entityId”:[“input_boolean.ligar_luz_do_ventilador”],“data”:“”,“dataType”:“json”,“mergeContext”:“”,“mustacheAltTags”:false,“outputProperties”:,“queue”:“none”,“x”:1180,“y”:1880,“wires”:[]},{“id”:“40f09d9e1117eda5”,“type”:“server”,“name”:“Home Assistant”,“version”:5,“addon”:true,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”,“connectionDelay”:true,“cacheJson”:true,“heartbeat”:false,“heartbeatInterval”:“30”,“areaSelector”:“friendlyName”,“deviceSelector”:“friendlyName”,“entitySelector”:“friendlyName”,“statusSeparator”:“: “,“statusYear”:“hidden”,“statusMonth”:“short”,“statusDay”:“numeric”,“statusHourCycle”:“default”,“statusTimeFormat”:“h:m”,“enableGlobalContextStore”:false},{“id”:“5c9f2c63485dd599”,“type”:“alexa-remote-account”,“name”:“jaime”,“authMethod”:“proxy”,“proxyOwnIp”:“192.168.0.30”,“proxyPort”:“3456”,“cookieFile”:”/homeassistant/senha”,“refreshInterval”:“5”,“alexaServiceHost”:“pitangui.amazon.com”,“pushDispatchHost”:“”,“amazonPage”:“amazon.com.br”,“acceptLanguage”:“pt-BR”,“onKeywordInLanguage”:“on”,“userAgent”:“”,“usePushConnection”:“on”,“autoInit”:“on”,“autoQueryActivityOnTrigger”:“on”}]’‘’

Substitui o input_boolean.ligar_luz_do_ventilador por um nó switch do NR e habilita o input.

Ai vc faz o fluxo assim:

1 - o sensor.interruptor_do_ventilador_da_sala_potencia tem que enviar verdadeiro ou falso para o swtich que vai substituir o input_boolean.ligar_luz_do_ventilador
2 - Esse switch vai enviar o comando para o broadlink_rm4_pro

pergunta boba,mas…pra um iniciante…

como faço para a entidade que envia consumo enviar verdadeiro ou falso?

seria assim ?

se pudesse montar um fluxo de exemplo usando meu codigo ficaria muinto agradecido, pois estou 3 horas quebrando cabeça e nehum resultado

‘’‘[{“id”:“a27e8117ce8f89ce”,“type”:“api-call-service”,“z”:“e17ca6c3b32a21f8”,“g”:“3043ee2142704218”,“name”:“”,“server”:“40f09d9e1117eda5”,“version”:5,“debugenabled”:false,“domain”:“remote”,“service”:“send_command”,“areaId”:,“deviceId”:[“19d0ef5734295e8a3121a65937f7db70”],“entityId”:[“remote.broadlink_rm4_pro”],“data”:“{\t "device": "ventilador sala",\t"command": "ligar luz"\t}”,“dataType”:“jsonata”,“mergeContext”:“”,“mustacheAltTags”:false,“outputProperties”:,“queue”:“none”,“x”:1110,“y”:1740,“wires”:[]},{“id”:“86535eee4297842f”,“type”:“alexa-remote-routine”,“z”:“e17ca6c3b32a21f8”,“g”:“3043ee2142704218”,“name”:“”,“account”:“5c9f2c63485dd599”,“routineNode”:{“type”:“smarthome”,“payload”:{“entity”:“8894b0d7-bc2b-4ab3-8b2b-30f389848d62”,“action”:“sceneActivate”}},“x”:1100,“y”:1780,“wires”:[]},{“id”:“8bc4fe242848a141”,“type”:“switch”,“z”:“e17ca6c3b32a21f8”,“g”:“3043ee2142704218”,“name”:“Check power”,“property”:“true”,“propertyType”:“msg”,“rules”:[{“t”:“btwn”,“v”:“2”,“vt”:“num”,“v2”:“12”,“v2t”:“num”}],“checkall”:“true”,“repair”:false,“outputs”:1,“x”:470,“y”:1740,“wires”:[[“0a5ba4d1ef599014”]]},{“id”:“823ce53833db5345”,“type”:“server-state-changed”,“z”:“e17ca6c3b32a21f8”,“g”:“3043ee2142704218”,“name”:“medidor de consumo do ventilador”,“server”:“40f09d9e1117eda5”,“version”:5,“outputs”:1,“exposeAsEntityConfig”:“”,“entityId”:“sensor.interruptor_do_ventilador_da_sala_potencia”,“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”}],“x”:180,“y”:1740,“wires”:[[“8bc4fe242848a141”,“43537c8f1cde0980”]]},{“id”:“0a5ba4d1ef599014”,“type”:“ha-switch”,“z”:“e17ca6c3b32a21f8”,“g”:“3043ee2142704218”,“name”:“”,“version”:0,“debugenabled”:false,“inputs”:1,“outputs”:2,“entityConfig”:“154af22ef745dc8e”,“enableInput”:true,“outputOnStateChange”:true,“outputProperties”:[{“property”:“outputType”,“propertyType”:“msg”,“value”:“state change”,“valueType”:“str”},{“property”:“payload”,“propertyType”:“msg”,“value”:“”,“valueType”:“entityState”}],“x”:690,“y”:1740,“wires”:[[“a27e8117ce8f89ce”],]},{“id”:“43537c8f1cde0980”,“type”:“switch”,“z”:“e17ca6c3b32a21f8”,“g”:“3043ee2142704218”,“name”:“Check power”,“property”:“false”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“0”,“vt”:“num”}],“checkall”:“true”,“repair”:false,“outputs”:1,“x”:470,“y”:1780,“wires”:[[“0a5ba4d1ef599014”]]},{“id”:“40f09d9e1117eda5”,“type”:“server”,“name”:“Home Assistant”,“version”:5,“addon”:true,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”,“connectionDelay”:true,“cacheJson”:true,“heartbeat”:false,“heartbeatInterval”:“30”,“areaSelector”:“friendlyName”,“deviceSelector”:“friendlyName”,“entitySelector”:“friendlyName”,“statusSeparator”:“: “,“statusYear”:“hidden”,“statusMonth”:“short”,“statusDay”:“numeric”,“statusHourCycle”:“default”,“statusTimeFormat”:“h:m”,“enableGlobalContextStore”:false},{“id”:“5c9f2c63485dd599”,“type”:“alexa-remote-account”,“name”:“jaime”,“authMethod”:“proxy”,“proxyOwnIp”:“192.168.0.30”,“proxyPort”:“3456”,“cookieFile”:”/homeassistant/senha”,“refreshInterval”:“5”,“alexaServiceHost”:“pitangui.amazon.com”,“pushDispatchHost”:“”,“amazonPage”:“amazon.com.br”,“acceptLanguage”:“pt-BR”,“onKeywordInLanguage”:“on”,“userAgent”:“”,“usePushConnection”:“on”,“autoInit”:“on”,“autoQueryActivityOnTrigger”:“on”},{“id”:“154af22ef745dc8e”,“type”:“ha-entity-config”,“server”:“40f09d9e1117eda5”,“deviceConfig”:“”,“name”:“luz do ventilador”,“version”:“6”,“entityType”:“switch”,“haConfig”:[{“property”:“name”,“value”:“luz do ventilador”},{“property”:“icon”,“value”:“mdi:lightbulb”},{“property”:“entity_picture”,“value”:“”},{“property”:“entity_category”,“value”:“”},{“property”:“device_class”,“value”:“”}],“resend”:false,“debugEnabled”:false}]’‘’

No nó check power do primeiro post vc liga um change em cada saída e coloca

sendo um true e outro false

primeiramente quero agradecer sua ajuda, nesse e em outros tópicos
e tambem me desculpar por não conseguir enteder e acabar criando mais dificuldades…

então…
lá no botão da dashbord coloco qual entidade?
pq do jeito que eu acho que entendi não funcionou…

veja bem, a luz do ventilador tem 3 acionamento/desacionamento,
pela alexa, pelo controle remoto original, e por um botão na dashboard do HA

então quando eu acionar pela alexa ou controle , o botão tem que acionar tbm para dar status de ligada ou desligado, e para que eu possa desativar por ele, e o contrario tbm…

seria como um treeway virtual

Vc pega o status de acordo com o consumo, correto?

O nó medidor pega o consumo, passa pelo no switch, sendo uma saída msg.payload = 0 e outra msg.payload > 0.

O nó change vai criar a msg.enable e enviar verdadeiro ou falso para a entrada do switch (azul) e atualizar o status. A entrada não gera nenhum comando na saída.

Na saída do nó switch (azul) vc faz a lógica de enviar o comando para o ir e alexa.

Não consigo criar um ex agora, se não conseguir eu tento mais tarde

O seu antigo ajudante será o que vc configurar no nó azul

Vai criar um Interruptor Ventilador no HA

[{"id":"f841509ef82ccda1","type":"tab","label":"Flow 8","disabled":false,"info":"","env":[]},{"id":"974179ab3ee35797","type":"server-state-changed","z":"f841509ef82ccda1","name":"medidor","server":"33803899.487d48","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"sensor.bomba_piscina_power","entityIdType":"exact","outputInitially":true,"stateType":"str","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":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":320,"y":320,"wires":[["7e5eda0e3ff125bc"]]},{"id":"c7af23b3d42dd3bb","type":"debug","z":"f841509ef82ccda1","name":"Status ON","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":240,"wires":[]},{"id":"7e5eda0e3ff125bc","type":"switch","z":"f841509ef82ccda1","name":"","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"2","vt":"num","v2":"12","v2t":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":320,"wires":[["aa697626fe79a1e4"],["efdf28358f6a016e"]]},{"id":"2f8bdc5fc2f6523f","type":"debug","z":"f841509ef82ccda1","name":"Status OFF","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":400,"wires":[]},{"id":"aa697626fe79a1e4","type":"change","z":"f841509ef82ccda1","name":"","rules":[{"t":"set","p":"enable","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":300,"wires":[["c7af23b3d42dd3bb","7b4a70c5080b7371"]]},{"id":"efdf28358f6a016e","type":"change","z":"f841509ef82ccda1","name":"","rules":[{"t":"set","p":"enable","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":340,"wires":[["2f8bdc5fc2f6523f","7b4a70c5080b7371"]]},{"id":"7b4a70c5080b7371","type":"ha-switch","z":"f841509ef82ccda1","name":"Ventilador","version":0,"debugenabled":false,"inputs":1,"outputs":2,"entityConfig":"8d8e17f54aac9c40","enableInput":true,"outputOnStateChange":true,"outputProperties":[{"property":"outputType","propertyType":"msg","value":"state change","valueType":"str"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":940,"y":320,"wires":[["538f0742c1ab7eda"],["538f0742c1ab7eda"]]},{"id":"538f0742c1ab7eda","type":"debug","z":"f841509ef82ccda1","name":"IR / Alexa","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1240,"y":320,"wires":[]},{"id":"33803899.487d48","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"8d8e17f54aac9c40","type":"ha-entity-config","server":"33803899.487d48","deviceConfig":"","name":"Ventilador","version":"6","entityType":"switch","haConfig":[{"property":"name","value":"Ventilador"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""}],"resend":false,"debugEnabled":false}]

era assim que tinha feito…

Mas por algum motivo não funcionava

Agora parece funciona…

Fazer mais teste amanhã e dou um feedback

bom dia…

esta funcionando de acordo

muito obrigado mais uma vez por sua ajuda,
com forma de agradecimento,
se quiser tomar uma coca, ou um latão eu pago :handshake: :handshake: :handshake: