[RELEASE] Home Assistant Device Bridge (HADB)

No, I meant for each websocket event, we handle certain attributes in addition to just the response?.event?.data?.new_state?.state, specifically certain thing in response?.event?.data?.new_state?.attributes, depending on the type of device.

For example, for "fan" class:
def speed = response?.event?.data?.new_state?.attributes?.speed?.toLowerCase()
def percentage = response?.event?.data?.new_state?.attributes?.percentage

So, we would have to decide whether to disregard the whole event update if any of it (or maybe just state?) is invalid. That would be easier than sending some attribute updates on the Hubitat side and dropping some others.

What I know is this is the current data for my thermostat:

Current States
coolingSetpoint : 23.0
heatingSetpoint : 23.0
temperature : 20.0
thermostatFanMode : on
thermostatMode : unavailable
thermostatOperatingState : on
thermostatSetpoint : 23.0

so, only one attribute is set as unavailable. Whether that means that these attributes came in separately or that only that attribute was set as unavailable by HA in a more complete event, I do not know.

Well, thermostatMode comes from state:
def thermostat_mode = response?.event?.data?.new_state?.state

Do you think the other attributes are correct, otherwise? Could you try to get a debug log print of an event coming across with 'unavailable' for thermostatMode to see if the rest of the data is intact or missing?

@mboisson are you using the generic thermostat component? It seems odd that a functionning thermostat would report no thermostat mode.

If so, is your entity in HA using PRESETS instead of HVAC_MODE?

I have seen "unknown" in my logs, therefore my code checks for both values, "unavailable" and "unknown".
I'm not sure but could it be that "unknown" is the value for new or resetted devices?

Hmmm, I just looked into my old log files and e.g. my device "prtCanon Black" (ink state of my Canon printer) is switched between "70%", "unavailable", and "unknown" in only 2 minutes!

Well ok. @tomw I think we could completely disregard the event if it is reporting "unavailable" or "unknown". Two states which are foreign to HE.

The thermostat seems to be a special case though. I suspect it is related to the discordance between the two implementations of climate control. If so, I suggest we let the unavailable state go through for that one for now unless we wish to rework the thermostat support.

1 Like

IMHO it's very important to have a choice for
a) getting the last real value (e.g. ink state), or
b) getting the actual value, even 'unavailable' etc. (e.g. printer state).

Maybe it's possible to just add a "validValue", where the last real value is stored; Then the already existing "value" and "valueStr" can remain unchanged... :thinking:

My understanding is that if the device state becomes unavailable, there is no new value to report. If we disregard that event, the current value will remain unchanged.

I understand. But sometimes even "unavailable" is an important information, e.g. when my printer is not reachable I should not try to print... :thinking:

Maybe we could see "unavailable" just as a boolean value? NO

Yes, I do.

Here is a log of events when I disconnected a thermostat:

dev:462022-12-06 17:57:44.359debugparse: domain: climate, device_class: null, entity: climate.cuisine, newVals: [unavailable], friendly: Cuisine
dev:462022-12-06 17:57:44.347debugparse(): description = {"id":1,"type":"event","event":{"event_type":"state_changed","data":{"entity_id":"climate.cuisine","old_state":{"entity_id":"climate.cuisine","state":"heat","attributes":{"hvac_modes":["heat","off"],"min_temp":5,"max_temp":30,"current_temperature":23.0,"temperature":23.0,"icon":"mdi:radiator","friendly_name":"Cuisine","supported_features":1},"last_changed":"2022-12-06T22:57:20.754390+00:00","last_updated":"2022-12-06T22:57:20.754390+00:00","context":{"id":"01GKMTGVVJF5NEPNH8VGY602CB","parent_id":null,"user_id":null}},"new_state":{"entity_id":"climate.cuisine","state":"unavailable","attributes":{"hvac_modes":["heat","off"],"min_temp":5,"max_temp":30,"icon":"mdi:radiator","friendly_name":"Cuisine","supported_features":1},"last_changed":"2022-12-06T22:57:43.185031+00:00","last_updated":"2022-12-06T22:57:43.185031+00:00","context":{"id":"01GKMTHHRH4S4VTA9RSXVPBP27","parent_id":null,"user_id":null}}},"origin":"LOCAL","time_fired":"2022-12-06T22:57:43.185031+00:00","context":{"id":"01GKMTHHRH4S4VTA9RSXVPBP27","parent_id":null,"user_id":null}}}
dev:462022-12-06 17:57:44.333debugparse: domain: sensor, device_class: power, entity: sensor.cuisine_power, newVals: [unavailable], friendly: Cuisine Power
dev:462022-12-06 17:57:44.320debugparse(): description = {"id":1,"type":"event","event":{"event_type":"state_changed","data":{"entity_id":"sensor.cuisine_power","old_state":{"entity_id":"sensor.cuisine_power","state":"1624","attributes":{"state_class":"measurement","unit_of_measurement":"W","device_class":"power","icon":"mdi:power-plug","friendly_name":"Cuisine Power"},"last_changed":"2022-12-06T22:57:20.754154+00:00","last_updated":"2022-12-06T22:57:20.754154+00:00","context":{"id":"01GKMTGVVJG9CVKAJCMQFB9F5E","parent_id":null,"user_id":null}},"new_state":{"entity_id":"sensor.cuisine_power","state":"unavailable","attributes":{"state_class":"measurement","unit_of_measurement":"W","device_class":"power","icon":"mdi:lan-disconnect","friendly_name":"Cuisine Power"},"last_changed":"2022-12-06T22:57:43.184751+00:00","last_updated":"2022-12-06T22:57:43.184751+00:00","context":{"id":"01GKMTHHRGJD1XM3HY9QY60G99","parent_id":null,"user_id":null}}},"origin":"LOCAL","time_fired":"2022-12-06T22:57:43.184751+00:00","context":{"id":"01GKMTHHRGJD1XM3HY9QY60G99","parent_id":null,"user_id":null}}}
dev:462022-12-06 17:57:44.301debugparse(): description = {"id":1,"type":"event","event":{"event_type":"state_changed","data":{"entity_id":"sensor.cuisine_temperature","old_state":{"entity_id":"sensor.cuisine_temperature","state":"23.0","attributes":{"state_class":"measurement","unit_of_measurement":"°C","device_class":"temperature","icon":"mdi:thermometer-high","friendly_name":"Cuisine Temperature"},"last_changed":"2022-12-06T22:57:20.753906+00:00","last_updated":"2022-12-06T22:57:20.753906+00:00","context":{"id":"01GKMTGVVHSMZTXX005HXFWTG5","parent_id":null,"user_id":null}},"new_state":{"entity_id":"sensor.cuisine_temperature","state":"unavailable","attributes":{"state_class":"measurement","unit_of_measurement":"°C","device_class":"temperature","icon":"mdi:thermometer-off","friendly_name":"Cuisine Temperature"},"last_changed":"2022-12-06T22:57:43.184460+00:00","last_updated":"2022-12-06T22:57:43.184460+00:00","context":{"id":"01GKMTHHRGW4WMTZTK8DEFM006","parent_id":null,"user_id":null}}},"origin":"LOCAL","time_fired":"2022-12-06T22:57:43.184460+00:00","context":{"id":"01GKMTHHRGW4WMTZTK8DEFM006","parent_id":null,"user_id":null}}}
dev:462022-12-06 17:57:21.920debugparse(): description = {"id":1,"type":"event","event":{"event_type":"state_changed","data":{"entity_id":"climate.cuisine","old_state":{"entity_id":"climate.cuisine","state":"unavailable","attributes":{"hvac_modes":["heat","off"],"min_temp":5,"max_temp":30,"icon":"mdi:radiator","friendly_name":"Cuisine","supported_features":1},"last_changed":"2022-12-06T22:56:41.718534+00:00","last_updated":"2022-12-06T22:56:41.718534+00:00","context":{"id":"01GKMTFNQPPVPAM8QD2F2RFVV1","parent_id":null,"user_id":null}},"new_state":{"entity_id":"climate.cuisine","state":"heat","attributes":{"hvac_modes":["heat","off"],"min_temp":5,"max_temp":30,"current_temperature":23.0,"temperature":23.0,"icon":"mdi:radiator","friendly_name":"Cuisine","supported_features":1},"last_changed":"2022-12-06T22:57:20.754390+00:00","last_updated":"2022-12-06T22:57:20.754390+00:00","context":{"id":"01GKMTGVVJF5NEPNH8VGY602CB","parent_id":null,"user_id":null}}},"origin":"LOCAL","time_fired":"2022-12-06T22:57:20.754390+00:00","context":{"id":"01GKMTGVVJF5NEPNH8VGY602CB","parent_id":null,"user_id":null}}}
dev:462022-12-06 17:57:21.894debugparse(): description = {"id":1,"type":"event","event":{"event_type":"state_changed","data":{"entity_id":"sensor.cuisine_power","old_state":{"entity_id":"sensor.cuisine_power","state":"unavailable","attributes":{"state_class":"measurement","unit_of_measurement":"W","device_class":"power","icon":"mdi:lan-disconnect","friendly_name":"Cuisine Power"},"last_changed":"2022-12-06T22:56:41.718281+00:00","last_updated":"2022-12-06T22:56:41.718281+00:00","context":{"id":"01GKMTFNQPNSTEC7EH6D654HMJ","parent_id":null,"user_id":null}},"new_state":{"entity_id":"sensor.cuisine_power","state":"1624","attributes":{"state_class":"measurement","unit_of_measurement":"W","device_class":"power","icon":"mdi:power-plug","friendly_name":"Cuisine Power"},"last_changed":"2022-12-06T22:57:20.754154+00:00","last_updated":"2022-12-06T22:57:20.754154+00:00","context":{"id":"01GKMTGVVJG9CVKAJCMQFB9F5E","parent_id":null,"user_id":null}}},"origin":"LOCAL","time_fired":"2022-12-06T22:57:20.754154+00:00","context":{"id":"01GKMTGVVJG9CVKAJCMQFB9F5E","parent_id":null,"user_id":null}}}
dev:462022-12-06 17:57:21.874debugparse(): description = {"id":1,"type":"event","event":{"event_type":"state_changed","data":{"entity_id":"sensor.cuisine_temperature","old_state":{"entity_id":"sensor.cuisine_temperature","state":"unavailable","attributes":{"state_class":"measurement","unit_of_measurement":"°C","device_class":"temperature","icon":"mdi:thermometer-off","friendly_name":"Cuisine Temperature"},"last_changed":"2022-12-06T22:56:41.718025+00:00","last_updated":"2022-12-06T22:56:41.718025+00:00","context":{"id":"01GKMTFNQPEKN39AEB5R0ZAGTB","parent_id":null,"user_id":null}},"new_state":{"entity_id":"sensor.cuisine_temperature","state":"23.0","attributes":{"state_class":"measurement","unit_of_measurement":"°C","device_class":"temperature","icon":"mdi:thermometer-high","friendly_name":"Cuisine Temperature"},"last_changed":"2022-12-06T22:57:20.753906+00:00","last_updated":"2022-12-06T22:57:20.753906+00:00","context":{"id":"01GKMTGVVHSMZTXX005HXFWTG5","parent_id":null,"user_id":null}}},"origin":"LOCAL","time_fired":"2022-12-06T22:57:20.753906+00:00","context":{"id":"01GKMTGVVHSMZTXX005HXFWTG5","parent_id":null,"user_id":null}}}

I am trying to get this going. I have HA in docker, latest version. I input the ip, and long lived token.
I keep getting this. Any thoughts on what i should try?

Are you able to reach your HA frontend with the same IP and Port you define in HADB?
Are you using a secure connection?

Will this work with/ is there a version for Homebridge? I just got mine setup the way I want (which took several hours and several resets) and I just found this page and don't want to start from scratch.

Was media player added as a device that can be bridged from HA to HE? Thanks for all the work on this integration!

Media player was not added.

I guess that was intentional?

Is it unlikely to be added?

We have sort of shied away from more complex device types, like the music player would be.

This was based on having done the work to support thermostat types and it taking a lot of work to make them work as expected and to work around subtle differences in how different HA integrations and devices worked.

In the end, even though the device classes appear similar between HA and HE, it seemed to end up being a better choice to integrate more complicated and/or specialized devices directly with HE or to just keep controlling them directly from HA.

With that said, I'd be willing to take a look at it, because I'm always looking for a good music player integration. Which integration are you using on the HA side?

1 Like

Thanks for considering, and I can understand if it doesn’t quite work to include certain device types, including a media player/music player.

I just started looking into the Denon HEOS integration in HA.

Technically, there is a Hubitat integration, but it’s one of @dman2306’s apps, which means it’s no longer supported.

It’s still working but I was just trying to stay ahead of any issues in case an update in the future either on the Hubitat or HEOS end introduces a breaking change.

Another good one is Apple TVs and HomePod minis (they're both using the same pyatv framework in HA). The HomePod mini can be used for TTS in HA. The Apple TV can be tuned to a specific streaming service via HA's integration. I imagine the HomePod mini might be a bit more straightforward.