remne / p1ib

P1 Interface Bridge
Other
56 stars 5 forks source link

Feature request: Additions to Home assistant auto discovery #1

Closed egeback closed 2 years ago

egeback commented 2 years ago

Hi

The home assistant MQTT auto discovery has the possibility to group multiple entries into devices for better mapping. Looking at the current implementation in p1ib it does not to expose this. The optional field is described here: https://www.home-assistant.io/integrations/sensor.mqtt/#device.

Also the availability tag could be good if data varies or the unit is closed down. Described here https://www.home-assistant.io/integrations/sensor.mqtt/#availability. (This probably needs that p1ib also needs a birth and will message to be added)

Current exposed json:

{
  "name": "p1ib_active_power_minus_l1",
  "stat_t": "homeassistant/sensor/p1ib/p1ib_active_power_m_l1/state",
  "device_class": "energy",
  "unit_of_measurement": "kW",
  "state_class": "measurement"
}

example from zigbee2mqtt:

{
  "availability": [
    {
      "topic": "zigbee2mqtt/bridge/state"
    }
  ],
 "device": {
    "identifiers": [
      "zigbee2mqtt_0x84fd27fffe6e1d13"
    ],
    "manufacturer": "IKEA",
    "model": "TRADFRI ON/OFF switch (E1743)",
    "name": "....",
    "sw_version": "Zigbee2MQTT 1.21.2"
  },
...
}
zigbee2mqtt/bridge/state: online or offline

Regards, Marky

remne commented 2 years ago

Hi! Thanks for the proposal. I've added the device part of the sensor registration (will add a new development firmware later today). However I fail to see what usecase the availability attribute/topic would be? :) I would think in usecase where you have a hub for example or similar where lots of other hardware sensors exists that communicate between this hub/bridge. But in the case of the p1ib, I dont know? Its hard to change availability to offline when the p1ib is disconnected from Wi-Fi accesspoint or possible dead due to power cycling of the p1 port.

One usecase would be the initial installation where possible the AMS:s P1 port is yet activated, but it might be a bit overkill to have this information in each sensor for that one time. Also its quite easy to just look in the web ui on the "Meter Telegrams" values if any messages from the meter is sent.

Regards, Andreas

egeback commented 2 years ago

Hi

Great, looking forward to the release.

For the feature request on availability the use case would be if for some reason we stop getting data at all. So the availability info as you see for Zigbee2Mqtt is only one status for the device not the individual sensors. And on the use case, automation could detect issue and more constant storage of data in HA if data is missing.

Regards, Marky

remne commented 2 years ago

Hi, Yes, that is true I suppose. I'll look into it! In the meantime there is a development firmware build you can try out (build b0524da in the p1ib firmware meny), if you want, which adds the device attribute.

Regards, Andreas

egeback commented 2 years ago

Hi

Tested the development build and it looks like the device auto discover addition works as expected.. Thanks.

Regards, Marky

remne commented 2 years ago

Hi Marty, The latest development firmware have the availability option enabled, if you wanna try it out!

Cheers, Andreas

egeback commented 2 years ago

Hi Andreas,

I have tested the build and it works as expected. Tested a reboot and the state was changed.

Topic: p1ib/.../state

image

So from my perspective the request is fulfilled, but I guess you want to make a stable release to close the issue.

Best Regards, Marky

remne commented 2 years ago

Feature in release 97b55c9.