NSPManager / NSPanelManager

Sonoff NSPanel custom firmware for responsive and intuitive use
https://nspanelmanager.com/
128 stars 10 forks source link

Home Assistant mqtt auto discovery error in Openhab #60

Closed cablesandcoffee closed 10 months ago

cablesandcoffee commented 11 months ago

Openhab has support for auto discovery of home assistant mqtt entities formatted in a HA mqtt labeling standard. Of some reason the auto discovery does not work for the NSPanel Manager project in Openhab. This is what the openhab log reports when the NSPanel Manager starts:

HomeAssistant discover error: invalid configuration of thing Kitchen Zink_screen component switch: Cannot parse channel configuration JSON

I have other project's mqtt entities being auto discovered in Openhab (zigbee2mqtt for example) so I was trying to figure out what the difference was between NSPM projects labeling and other projects that are working in Openhab. I found a small difference and I would like to report it and hopefully we can make it work for Openhab as well.

Here is an example of a z2m config payload: {"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"}],"device":{"identifiers":["zigbee2mqtt_0xd0cf5efffeb3fa76"],"manufacturer":"IKEA","model":"TRADFRI control outlet (E1603/E1702/E1708)","name":"Outlet Mirror Screen","sw_version":"2.0.024"},"enabled_by_default":false,"entity_category":"diagnostic","icon":"mdi:signal","name":"Outlet Mirror Screen linkquality","state_class":"measurement","state_topic":"zigbee2mqtt/Outlet Mirror Screen","unique_id":"0xd0cf5efffeb3fa76_linkquality_zigbee2mqtt","unit_of_measurement":"lqi","value_template":"{{ value_json.linkquality }}"}

and here a current NSPM config payload: {"device": {"identifiers": ["NSPanel-0C:DC:7E:31:F9:44"], "connections": [["mac", "0C:DC:7E:31:F9:44"]], "name": "Entryway", "model": "NSPanel", "manufacturer": "Sonoff"}, "availability": {"topic": "nspanel/Entryway/status", "value_template": "{{ value_json.state }}"}, "device_class": "temperature", "unit_of_measurement": "\u00b0C", "name": "Entryway temperature", "state_topic": "nspanel/Entryway/temperature_state"}

The big difference that I saw is that z2m has two [] wrapping around the availability data. NSPM does not.

I tried adding two [] in the NSPM payload and then the entity was auto discovered in Openhab.

Is this something that we could change? What's is the actual technical difference? Only thing I can see is that it makes it work in Openhab at least. :)

tpanajott commented 11 months ago

Will have to confirm this is working with home Assistant but given that is OK it will be quick to fix.

tpanajott commented 11 months ago

Can confirm fix from pull request. Will close issue.

tpanajott commented 11 months ago

Sorry, closed the wrong issue but please try latest main and close if you find it fixed.

cablesandcoffee commented 11 months ago

Wooho! Works! One little detail though. Is it possible to get NSPM in somewhere in the naming (before mac maybe) for ease of searching after just NSPM in the Openhab inbox?

Right now it looks like this in Openhab: Screenshot from 2023-07-21 15-03-08

As reference a zigbee2mqtt entity shows up with zigbee2mqtt in naming as well so you can easily see what systems it comes from:

Screenshot from 2023-07-21 15-07-30

tpanajott commented 11 months ago

This seems to not be doable and still be compatible with Home Assistant (see issue #72). Perhaps some other attribute could be changed?

cablesandcoffee commented 11 months ago

I will look into this when I have time and see how it behaves now with the new update.

cablesandcoffee commented 10 months ago

Magically fixed. Guess they know what they're doing over there at the Openhab side. I tried to find exactly what they did but the problem disappeared in Openhab 4.0.2.1. Or it might have been fixed in Openhab 4 which I just migrated to. Don't remember if I checked this before I accidentally upgraded to 4.0.2.1.