jason0x43 / hacs-hubitat

A Hubitat integration for Home Assistant
MIT License
196 stars 48 forks source link

Node Red with Hubitat Devices #87

Closed tcholston closed 3 years ago

tcholston commented 3 years ago

Hubitat devices respond in Home Assistant with manual entity commands and GUI switches on lovelace cards. Yet will not perform commands in Node-Red correctly. Sometimes it will miss or not even respond.

jason0x43 commented 3 years ago

Could you provide a bit more information about what you’re trying to do, how you’re running commands, and what specific issues you’re seeing? I’m not aware of any current issues with NR.

tcholston commented 3 years ago

From NR I got the state of the light through Hubitat. That seems to be working fine. Yet when I attempt to have a stoptimer and then a command to turn off lights. The command goes through, yet it does not actually turn off the lights.

jason0x43 commented 3 years ago

Hmmm...is Node Red talking directly to Hubitat, or is it going through Home Assistant? I mean, if it's talking directly to Hubitat, then this integration wouldn't be involved.

tcholston commented 3 years ago

No. Node red / hubitat is talking through HA. I dont have MQTT setup through NR. It was working until my server went down. Now rebuilding... so maybe I missed something. Yet, I dont think soo.

Only thing that changed is the hubitat is on a VLAN separate from the HA installation. Still able to talk or I would get states.

Does the Event server self advertise to the HA or vice versa?

jason0x43 commented 3 years ago

Ah, the different lan might be a problem. The integration tells Hubitat to send events to <home assistant host>:<event server port>. It determines the host address by sending a packet to Hubitat and getting the address of the outgoing interface that was used to send the packet.

This works great when everything's on the same local network. However, if HA and Hubitat are on different networks, you can manually configure the event server address in the integration's options (HA -> Configuration -> Integrations -> Hubitat -> Options). Note that you will need to manually set the event server port in this case as well.

tcholston commented 3 years ago

Ok.

0.10 is where my HA is.

10.10 is where my Hubitat is.

Under hubitat the Post sever is show 0.10:43205

Should I put that in HA or am I putting the 10.10:43205 in Event server?

Wanna do this so maybe you can put that in the docs if on VLAN this is how you have to do it.

jason0x43 commented 3 years ago

Looking at your original post, it doesn't seem like there's a problem with HA communicating with Hubitat:

Hubitat devices respond in Home Assistant with manual entity commands and GUI switches on lovelace cards. Yet will not perform commands in Node-Red correctly. Sometimes it will miss or not even respond.

There is no direct connection between this integration and Node Red. HA talks to Hubitat through this integration, and NR talks to HA. If HA can control Hubitat devices, then the integration is working properly, and you don't need to worry about the manual server setting. If NR is unable to control some devices, then it's likely a problem between NR and HA.

One thing to try is to enable debug logging for this integration in HA, then try to control a device through NR and see what log messages show up. If there are messages about commands being sent and events being received, that's good. If there are errors, it may help nail down what the specific issue is.

tcholston commented 3 years ago

This is manual on and off.

2020-12-07 16:44:50 DEBUG (MainThread) [custom_components.hubitat.light] Turning on Kitchen Light 2 with {} 2020-12-07 16:44:50 DEBUG (MainThread) [hubitatmaker.hub] Sending command on() to 9 2020-12-07 16:44:50 DEBUG (MainThread) [custom_components.hubitat.device] sent on to 9 2020-12-07 16:44:51 DEBUG (MainThread) [custom_components.hubitat.light] Turning on Kitchen Light 1 with {} 2020-12-07 16:44:51 DEBUG (MainThread) [hubitatmaker.hub] Sending command on() to 8 2020-12-07 16:44:51 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'switch', 'value': 'on', 'displayName': 'Kitchen Light 2', 'deviceId': '9', 'descriptionText': 'Kitchen Light 2 was turned on', 'unit': None, 'type': None, 'data': None} 2020-12-07 16:44:51 DEBUG (MainThread) [hubitatmaker.hub] Updating switch of 9 to on 2020-12-07 16:44:51 DEBUG (MainThread) [custom_components.hubitat.device] sent on to 8 2020-12-07 16:44:51 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'switch', 'value': 'on', 'displayName': 'Kitchen Light 1', 'deviceId': '8', 'descriptionText': 'Kitchen Light 1 was turned on', 'unit': None, 'type': None, 'data': None} 2020-12-07 16:44:51 DEBUG (MainThread) [hubitatmaker.hub] Updating switch of 8 to on 2020-12-07 16:45:15 DEBUG (MainThread) [hubitatmaker.hub] Sending command off() to 9 2020-12-07 16:45:15 DEBUG (MainThread) [custom_components.hubitat.device] sent off to 9 2020-12-07 16:45:15 DEBUG (MainThread) [custom_components.hubitat.light] Turning off Kitchen Light 1 2020-12-07 16:45:15 DEBUG (MainThread) [hubitatmaker.hub] Sending command off() to 8 2020-12-07 16:45:15 DEBUG (MainThread) [custom_components.hubitat.device] sent off to 8 2020-12-07 16:45:16 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'switch', 'value': 'off', 'displayName': 'Kitchen Light 2', 'deviceId': '9', 'descriptionText': 'Kitchen Light 2 was turned off', 'unit': None, 'type': None, 'data': None} 2020-12-07 16:45:16 DEBUG (MainThread) [hubitatmaker.hub] Updating switch of 9 to off 2020-12-07 16:45:16 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'switch', 'value': 'off', 'displayName': 'Kitchen Light 1', 'deviceId': '8', 'descriptionText': 'Kitchen Light 1 was turned off', 'unit': None, 'type': None, 'data': None} 2020-12-07 16:45:16 DEBUG (MainThread) [hubitatmaker.hub] Updating switch of 8 to off

This is with NR tying to them off.

2020-12-07 16:24:25 DEBUG (MainThread) [custom_components.hubitat.light] Turning on Kitchen Light 1 with {}
2020-12-07 16:24:25 DEBUG (MainThread) [hubitatmaker.hub] Sending command on() to 8
2020-12-07 16:24:25 DEBUG (MainThread) [custom_components.hubitat.device] sent on to 8
2020-12-07 16:24:26 DEBUG (MainThread) [custom_components.hubitat.light] Turning on Kitchen Light 2 with {}
2020-12-07 16:24:26 DEBUG (MainThread) [hubitatmaker.hub] Sending command on() to 9
2020-12-07 16:24:26 DEBUG (MainThread) [custom_components.hubitat.device] sent on to 9
2020-12-07 16:24:26 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'switch', 'value': 'on', 'displayName': 'Kitchen Light 1', 'deviceId': '8', 'descriptionText': 'Kitchen Light 1 was turned on', 'unit': None, 'type': None, 'data': None}
2020-12-07 16:24:26 DEBUG (MainThread) [hubitatmaker.hub] Updating switch of 8 to on
2020-12-07 16:24:26 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'switch', 'value': 'on', 'displayName': 'Kitchen Light 2', 'deviceId': '9', 'descriptionText': 'Kitchen Light 2 was turned on', 'unit': None, 'type': None, 'data': None}
2020-12-07 16:24:26 DEBUG (MainThread) [hubitatmaker.hub] Updating switch of 9 to on
2020-12-07 16:26:14 DEBUG (MainThread) [custom_components.hubitat.light] Turning off Kitchen Light 1
2020-12-07 16:26:14 DEBUG (MainThread) [hubitatmaker.hub] Sending command off() to 8
2020-12-07 16:26:14 DEBUG (MainThread) [custom_components.hubitat.device] sent off to 8
2020-12-07 16:26:15 DEBUG (MainThread) [custom_components.hubitat.light] Turning off Kitchen Light 2
2020-12-07 16:26:15 DEBUG (MainThread) [hubitatmaker.hub] Sending command off() to 9
2020-12-07 16:26:15 DEBUG (MainThread) [custom_components.hubitat.device] sent off to 9

It is like the hubitatmaker.hub is not receiving the command.

jason0x43 commented 3 years ago

The on command appears to be working in both cases -- the command is sent, and an update is received from Hubitat. However, no update is being received for the off command sent in the second set of log statements. Does it work in the manual case? (There's no off in the "manual on and off" log above.)

tcholston commented 3 years ago

The on command appears to be working in both cases -- the command is sent, and an update is received from Hubitat. However, no update is being received for the off command sent in the second set of log statements. Does it work in the manual case? (There's no off in the "manual on and off" log above.)

Updated with the pair.

Yes it works manually.

Yeah.... it totally looks like the off update is crapping out when through NR.

jason0x43 commented 3 years ago

Hmmm...that's odd. Node Red is not involved in the HA -> Hubitat communication. I mean, whether you use an HA UI toggle or a Node Red service call, you're telling HA to do something, and HA will behave the same in either case.

Just out of curiosity, how are you turning the lights on and off through Node Red? With service calls to light.turn_on' and light.turn_off?

tcholston commented 3 years ago

Manually on. Either through HA or Alexa. Then NR timer to turn off the lights.

As for being odd. Yes. Especially since nothing ultimately changed and we see HA communicating with HE. If it is not an integration issue, which we see that it isnt. We can close the issue. Seems the integration is fine. Just NR being stupid, which means I am barking up the wrong tree with you. :)

jason0x43 commented 3 years ago

Closing this since it sounds like the issue isn't related to this integration, but we can certainly reopen if it looks like it is.