spacemanspiff2007 / HABApp

Easy home automation with MQTT and/or openHAB
Apache License 2.0
54 stars 22 forks source link

Error when using Homie MQTT Items #110

Closed NickWaterton closed 2 years ago

NickWaterton commented 4 years ago

With the impending removal of the 1.x binding compatibility layer (in OH 3.0) I have been experimenting with homie MQTT items.

It looks like a promising way of getting third party devices into OH without having a specific 2.x (or 3.x) binding.

So I'm trying the ISY-Homie bridge. OH is very buggy with homie items, although it (kind of) auto discovers them.

So OH discovers a Dimmer item (from my ISY), OH inconveniently marks the dimmer channel as a Number Channel, but you can link it to a Dimmer Item, and it works as a Dimmer. Homie uses 0.0 to 1.0 for dimmers, though, so Habapp throws these errors when you change the value:

2020-02-05 11:08:12,314[                    HABApp]ERROR| __process_exception: Error 0.45 in on_sse_event:
2020-02-05 11:08:12,315[                    HABApp]ERROR| __process_exception: Traceback (most recent call last):
2020-02-05 11:08:12,315[                    HABApp]ERROR| __process_exception:   File "/home/nick/Scripts/HABApp/HABApp/openhab/oh_connection.py", line 110, in on_sse_event
2020-02-05 11:08:12,316[                    HABApp]ERROR| __process_exception:     __item.set_value(event.value)
2020-02-05 11:08:12,316[                    HABApp]ERROR| __process_exception:   File "/home/nick/Scripts/HABApp/HABApp/openhab/items/dimmer_item.py", line 19, in set_value
2020-02-05 11:08:12,317[                    HABApp]ERROR| __process_exception:     assert new_value is None, new_value
2020-02-05 11:08:12,317[                    HABApp]ERROR| __process_exception: AssertionError: 0.45
2020-02-05 11:08:28,509[                    HABApp]ERROR| __process_exception: Error 1.0 in on_sse_event:
2020-02-05 11:08:28,510[                    HABApp]ERROR| __process_exception: Traceback (most recent call last):
2020-02-05 11:08:28,510[                    HABApp]ERROR| __process_exception:   File "/home/nick/Scripts/HABApp/HABApp/openhab/oh_connection.py", line 110, in on_sse_event
2020-02-05 11:08:28,511[                    HABApp]ERROR| __process_exception:     __item.set_value(event.value)
2020-02-05 11:08:28,511[                    HABApp]ERROR| __process_exception:   File "/home/nick/Scripts/HABApp/HABApp/openhab/items/dimmer_item.py", line 19, in set_value
2020-02-05 11:08:28,512[                    HABApp]ERROR| __process_exception:     assert new_value is None, new_value
2020-02-05 11:08:28,512[                    HABApp]ERROR| __process_exception: AssertionError: 1.0

Although the Slider/Dimmer 'Item' works just fine in the interface, and if you query the value of the item, you get 0.0-100.0. You also can't send 'ON' or 'OFF' to these DimmerItems it only accepts numbers.

OH is obviously doing some internal processing of these homie events, to transform Items to Channels. It looks to me like you send 0.0-1.0 to the homie Item but the returned value is 0.0-100.0.

This isn't a bug as such, more like a new feature.

So if an item is linked to a homie Thing or Channel maybe we should transform 'ON'/'OFF' to 0-100, and accept that there is some low level transformation going on (and not throw an error).

Homie Channels look like this:

number mqtt:homie300:proliant:dimmer-44f0c61:dimmer#dimmer
string mqtt:homie300:proliant:dimmer-44f0c61:dimmer#paddleaction

They all start with mqtt:homie300 where 300 is the homie version (400 is the latest). proliant is my broker, dimmer-44f0c61 is the "Device Id" (from my ISY), and dimmer is the type of device.

The example is a dimmer switch, paddleaction is a string that gives the last switch activity ("ON", "OFF", "FastON" etc.).

The Items look like this:

Dimmer  NickOfficeLight_dimmer_homie   "Nicks's Office Dimmer[%d%%]"                              (gFF, FF_Office, Lights, homie)                { channel="mqtt:homie300:proliant:dimmer-44f0c61:dimmer#dimmer" }
Number  NickOfficeLight_homie          "Nicks's Office [%.2f]"                                    (gFF, FF_Office, Lights, homie)                { channel="mqtt:homie300:proliant:dimmer-44f0c61:dimmer#dimmer" }
String  NickOfficeLight_paddle_homie   "Nicks's Office Paddle [%s]"                               (gFF, FF_Office, Lights, homie)                { channel="mqtt:homie300:proliant:dimmer-44f0c61:dimmer#paddleaction" }

Where the Dimmer is 0-100, Number is 0.0-1.0.

I think that homie support is in it's early stage in OH, but it might be a project to put some basic support in Habapp for it.

spacemanspiff2007 commented 4 years ago

https://homieiot.github.io/specification/

spacemanspiff2007 commented 4 years ago

Imho the right way to to it would be to add homie support for HABApp and let HABApp also autogenerate the items in openhab.

spacemanspiff2007 commented 2 years ago

This issue seems stale so I'm closing it. Feel free to open it again.