Hi All,
I’m changing over my home from OpenHAB to HA and most things are coming across without issue.
I have the following light that uses the below OH config:
I have already looked at this document and I don’t understand how this works.
I have quite a few of these style of devices and just need a hand with the first two types.
state_topic: is the topic from which the current state of the light will be read. Must be “ON” or “OFF” by default. Use payload_on/ payload_off to change the default
command_topic: is the topic where state changes are published by HA. Same goes as above regarding the actual values.
Once again, if you are not more precise regarding what you don’t understand, we cannot help you precisely.
If the device can only be turned on/off and doesn’t allow for adjustment of brightness, you may wish to consider modeling it as an MQTT Switch instead of an MQTT Light entity. However, you’re not obligated to do that and you can model it as light if that’s your preference.
According to your openHAB example, this is the topic used to publish a command to the device:
/ESP-5-S-SW/gpio/12
In Home Assistant, that’s called the command_topic.
What is the topic that your device uses to report it’s current state? In Home Assistant, this topic is called the state_topic.
mqtt:
- switch:
unique_id: abc123xyz456
name: "Family Room Wall Light"
state_topic: <enter the topic used by the device to report its current state>
command_topic: "/ESP-5-S-SW/gpio/12"
payload_on: "1"
payload_off: "0"
state_on: "1"
state_off: "0"
If the device doesn’t report its current state then it operates in what Home Assistant calls “optimistic mode” (a command sent to the device is assumed to be received and executed because the device does not report its current state).
Hi Neil,
I ported my system across from openHAB to HASS some years ago after several months of parallel running with one MQTT broker. Both openHAB and HASS connected to the same instance of Mosquitto allowing automations and other config to be ported across one by one.
Similar to openHAB 2.0, MQTT devices can be defined manually or using HASS auto-discovery. The latter works is much easier for devices that support it (e.g. older Tasmota) as you configure the device once, not the automation platform.
The MQTT messages you posted suggest at least these devices are custom ESP-based modules, for which manual MQTT config might be easier in the short-term.
The hardest part of moving across from openHAB is shifting from a “Java-like” mindset (tabs) to “Python-like” paradigm (spaces, JSON/YAML). Consistent YAML indentation is painful at first, but prototype using the visual automation editor first THEN tweak. Most of my automations ended up a fraction of the size of openHAB once I’d masterd the dev tools to live-protoype Jinja2 templating functions (e.g. {{ object }}).
In general, HASS documentation is function with few examples BUT search for terms in this forum to find (usually) working code.
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.