NorthernMan54 / node-red-contrib-homebridge-automation

Homebridge and Node-RED Integration
Apache License 2.0
107 stars 18 forks source link

'hb event' is triggered again and again #67

Closed Staubgeborener closed 3 years ago

Staubgeborener commented 3 years ago

I need a flow that checks every X seconds whether the light is still on. After X runs, the light should be switched off if it is still on. If the light comes on beforehand, then the flow should be interrupted (i.e. no more loop) - I haven't implemented the last one yet, but there would only have to be a msg.payload.On == false in the first switch. But that's not the point...

Now I've noticed that hb event is always retriggered if the light is still on, you can see this in the second screenshot. This means that the loop is always restarted and my initialization variable is set back to 0. Is there a way to switch off this new trigger or a flow that somehow intercepts it?

flow debug

My flow:

[{"id":"9508964c.ba25e8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"7867e688.db51d8","type":"hb-event","z":"9508964c.ba25e8","name":"Deckenlampe Abstellraum","Homebridge":"homebridge","Manufacturer":"Philips","Service":"Lightbulb","device":"homebridgeCC:22:3D:E3:CE:31PhilipsDeckenlampe Abstellraum00000043","conf":"88398400.a5a76","x":410,"y":400,"wires":[["90fb23b6.921ce8"]]},{"id":"8b1642df.c1c4b8","type":"hb-control","z":"9508964c.ba25e8","name":"Deckenlampe Abstellraum","Homebridge":"homebridge","Manufacturer":"Philips","Service":"Lightbulb","device":"homebridgeCC:22:3D:E3:CE:31PhilipsDeckenlampe Abstellraum00000043","conf":"88398400.a5a76","x":1640,"y":400,"wires":[]},{"id":"d38be6c9.0ac0b","type":"function","z":"9508964c.ba25e8","name":"turn off light","func":"msg.payload = {\"On\": false, \"Brightness\": 0 }\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1388,"y":400,"wires":[["8b1642df.c1c4b8"]]},{"id":"3532b3dd.7f357c","type":"function","z":"9508964c.ba25e8","name":"","func":"var i = flow.get(\"i\");\ni++;\nflow.set(\"i\", i);\nmsg.payload = i;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":960,"y":400,"wires":[["8fd5aae3.80d68","4bcf72d4.5e19ec"]]},{"id":"8fd5aae3.80d68","type":"switch","z":"9508964c.ba25e8","name":"","property":"i","propertyType":"flow","rules":[{"t":"lt","v":"10","vt":"str"},{"t":"gte","v":"10","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1130,"y":400,"wires":[["4c45cade.fe84dc"],["d38be6c9.0ac0b"]]},{"id":"4c45cade.fe84dc","type":"delay","z":"9508964c.ba25e8","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1040,"y":320,"wires":[["3532b3dd.7f357c"]]},{"id":"4bcf72d4.5e19ec","type":"debug","z":"9508964c.ba25e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":480,"wires":[]},{"id":"90fb23b6.921ce8","type":"switch","z":"9508964c.ba25e8","name":"","property":"payload.On","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":610,"y":400,"wires":[["4bcf72d4.5e19ec","b718be33.b4d65"]]},{"id":"b718be33.b4d65","type":"function","z":"9508964c.ba25e8","name":"set var","func":"flow.set(\"i\", 0);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":400,"wires":[["3532b3dd.7f357c"]]},{"id":"88398400.a5a76","type":"hb-conf","z":"","username":"031-45-154"}]
NorthernMan54 commented 3 years ago

I ran this in my setup and after changing the configuration to one of my lights I was not able to recreate the issue. For me your 10 second timer loop works perfectly.

What plugin is controlling your lights? For the test I was using my Homebridge-hue lights

Staubgeborener commented 3 years ago

What plugin is controlling your lights? For the test I was using my Homebridge-hue lights

Hue lightbulbs are connected to phoscon (only conbee II Stick, no hue bridge). And phoscon is integrated with homebridge-hue plugin to homebridge.

homebridge config:


{
            "name": "Hue",
            "users": {
                "XXX": "XXX"
            },
            "forceCt": true,
            "heartrate": 2,
            "hosts": [
                "IP:port"
            ],
            "lights": true,
            "nativeHomeKitLights": true,
            "nativeHomeKitSensors": true,
            "nupnp": true,
            "linkButton": true,
            "resource": true,
            "sensors": true,
            "platform": "Hue",
            "wallSwitch": true
        },

Maybe changing the heartrate...

Edit: Nope, heartrate is not the problem.

Staubgeborener commented 3 years ago

Very interesting - i just replaced the node with node-red-contrib-deconz. The device is the same. But now it works.

flow

NorthernMan54 commented 3 years ago

Weird

I was going to suggest creating a simple nope that doesn't pass along duplicate messages to workaround this

Staubgeborener commented 3 years ago

Fix this with another plugin. This is a solution for my scenario, so i close this issue. I do not know whether it is actually a reputable error.