jomjol / AI-on-the-edge-device

Easy to use device for connecting "old" measuring units (water, power, gas, ...) to the digital world
https://jomjol.github.io/AI-on-the-edge-device-docs/
6.08k stars 654 forks source link

Publish GPIO settings with MQTT is not included in HA auto discovery #3302

Open Dag0d opened 1 month ago

Dag0d commented 1 month ago

The Problem

When GPIO Pins are configured they are published to MQTT if "GPIO1 Enable MQTT" is checked this is as expected. But it is not included in the HA auto discovery message. Maybe there was a reason behind this decision, if so I´m happy to hear it.

Version

1.5.7 and 1.6.0 RC2

Logfile

I guess no need for a log file

Expected Behavior

No response

Screenshots

No response

Additional Context

No response

caco3 commented 1 month ago

The reason simply is that I was not aware of it when I implemented the discovery topics. If somebody wants to extend it, I am happy to test it, but don't currently have the time to extend it myself.

caco3 commented 1 month ago

@Dag0d I am happy to extend the discovery topics to reflect the control topics we have. Currently there are 3 of them:

They are already documented in https://jomjol.github.io/AI-on-the-edge-device-docs/MQTT-API/#control

How ever I struggle to get them working (make them show up in HA). I tried it like in https://community.home-assistant.io/t/add-entity-to-mqtt-device/540949/7 but nothing showed up in HA. So if somebody is willing to provide the needed config topics, I will add it. if not, I will move it aside for now.

Slider0007 commented 1 month ago

@caco3: I only have it already implemented for flow start:

.configTopic = "flow_start",
.friendlyName = "Manual Cycle Start",
.icon = "timer-play-outline",
.deviceClass = "update",
.entityCategory = "config"

topicFull = "homeassistant/button/" + node_id + "/" + configTopic + "/config";

In HA: image

caco3 commented 1 month ago

@Slider0007 Nice. Can you prepare a branch with it? I then can check to extend it.

Other question: Do you know why we need a payload here? https://github.com/jomjol/AI-on-the-edge-device/blob/43f15fcba3416a53bea428bb6e06b236aa72b3a4/code/components/jomjol_mqtt/interface_mqtt.cpp#L391

Slider0007 commented 1 month ago

@Slider0007 Nice. Can you prepare a branch with it? I then can check to extend it.

Other question: Do you know why we need a payload here?

https://github.com/jomjol/AI-on-the-edge-device/blob/43f15fcba3416a53bea428bb6e06b236aa72b3a4/code/components/jomjol_mqtt/interface_mqtt.cpp#L391

If I remember right, there is no specific reason. Maybe a small safety feature to not disturbing the cycle by mistake, but in the end only definition...

caco3 commented 1 month ago

ok, then I will throw it out. Reason is that i am not sure if HA supports a switch cmd with payload. also, IIRC, if you trigger it while it is already running, nothing happens.

Slider0007 commented 1 month ago

ok, then I will throw it out. Reason is that i am not sure if HA supports a switch cmd with payload.

I have it already implemented the same way (with payload) in my fork and the start trigger is working in home assistant. So there should be no limitation, but still could be removed.

Slider0007 commented 1 month ago

@caco3: I prepared a branch with the possible changes for the flow start button discovery: https://github.com/jomjol/AI-on-the-edge-device/tree/extend-ha-discovery

It's not tested yet, though. Can be extended further...