RogerSelwyn / mqtt_discoverystream_ha

Extension of HA mqtt_statestream integration with discovery config publishing
3 stars 5 forks source link

Discoverable #31

Closed pergolafabio closed 3 days ago

pergolafabio commented 4 days ago

Hi,

I'm using this integration to expose lights/switches to Openhab...

mqtt_discoverystream_alt:
  base_topic: openhab
  publish_attributes: true
  publish_timestamps: false
  publish_discovery: true
  include:
    domains:
      - light
      - switch

In MQTT explorer, i see the entities being created on the base topic "openhab"

image

So far so good, but if i install OpenHab, it cant discover the entities? only the ones with hmd/homeassistant? What am i missing here? How can i make the discoverable?

image thnx

RogerSelwyn commented 4 days ago

I have no idea how OpenHab works, so no idea what it is doing. That said, the way you have mqttds configured the discovery topics are within the openhab topic.

The discovery messages are key, and are separate from the status messages. Discovery messages tell home Assistant where to find the statuses messages.

Normally with home Assistant they would be within the homeassistant topic when you have something like zigbee2mqtt since the entities detailed there would be new to the home Assistant instance.

I would imagine openhab will be looking in the homeassistant topic. You can configure where they are put using the ‘discovery_topic’ configuration setting. But if you set that to ‘homeassistant’ you will find that all your entities will get recreated in your home Assistant instance (assuming you have it setup to defaults) because it thinks they are new, which is why the Integration doesn’t output there as standard (it puts them under base_topic).

So you need to also be able to tell openhab where to find them, which I can’t help you with.

pergolafabio commented 4 days ago

Ah ok , in Openhab its an "HA binding" , so probably follow the defaults... I think I need to create every mqtt entity manual in openhab ... A lot of copy/paste then :-)

pergolafabio commented 3 days ago

hey @RogerSelwyn , creating custom mqtt entities are working , 1 question however, if i restart Openhab, openhab things the mqtt is offline, as soon as i turn on/off light manually, the light comes online in Openhab Probably when i restart Openhab, its doesnt know the availability (online vs offline) topic?

image

is it somehow possible to retain that message/topic? image

UID: mqtt:topic:4195962e3b
label: Bureau
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: offline
  availabilityTopic: openhab/light/bureau/availability
  payloadAvailable: online
bridgeUID: mqtt:broker:aff82bad06
channels:
  - id: Bureau
    channelTypeUID: mqtt:switch
    label: On/Off Switch
    configuration:
      commandTopic: openhab/light/bureau/set_light
      stateTopic: openhab/light/bureau/state
      transformationPattern: JSONPATH:$.state
      off: '{ "state": "OFF" }'
      on: '{ "state": "ON" }'

or i can also work without the " availabilityTopic: openhab/light/bureau/availability" but is then possible to send the state of the light at peridoc intervals? so openhab knows at least the state of the light for example? or how can i solve this?

RogerSelwyn commented 3 days ago

I’d need to look in detail at that

RogerSelwyn commented 3 days ago

You can send am online message to the birth_topic and it will re-send discovery and status for all entities - https://github.com/RogerSelwyn/mqtt_discoverystream_ha#topic-handling

Or you can call the publish_discovery_state HA service to get them resent.

I went though some time ago removing retention for messages, because it caused other issues. This is the thread if you want to read about it - https://github.com/RogerSelwyn/mqtt_discoverystream_ha/issues/8

pergolafabio commented 3 days ago

Ok, gonna test the publish state service, that will do, thnx!