Hi guys,
I am moving from Domoticz to Home Assistant. I updated my coffeemachine with a NodeMCU which can detect the state of the machine (brewing, heating, idle, off, error) and allows me to turn the machine on/off and brew remotely.
I created this NodeMCU device when I only had domoticz and therefore it sends messages directly to domoticz. The switches for machine on/off and brew on/off I can easily include in Home Assistant throught MQTT messages from domoticz.
However, the state of the machine is captured in a so called selector in Domoticz. I can acces the current state through MQTT, e.g.:
domoticz/out/coffeeMachineState
{
"Battery" : 255,
"LastUpdate" : "2023-02-17 11:12:21",
"LevelActions" : "||||",
"LevelNames" : "Off|HeatingUp|HeatedIdle|Brewing|Error",
"LevelOffHidden" : "false",
"RSSI" : 12,
"SelectorStyle" : "0",
"description" : "",
"dtype" : "Light/Switch",
"hwid" : "2",
"id" : "0001412B",
"idx" : 219,
"name" : "coffeeMachineState",
"nvalue" : 0,
"stype" : "Selector Switch",
"svalue1" : "0",
"switchType" : "Selector",
"unit" : 1
}
The svalue1 variable indicates the state, so it can be “0”, “10”, “20”, …
How do I properly get this state in Home Assistant? I tried using mqtt select, with no luck. The state is always “Test Select”. The other states are available in the dropdown, but the current state does not get updated.
select:
- name: "Test Select"
command_topic: "domoticz/out/coffeeMachineState"
state_topic: "domoticz/out/coffeeMachineState"
value_template: |-
{% if value_json.svalue1 == '0' %}
"Off"
{% elif value_json.svalue1 == '10' %}
"HeatingUp"
{% elif value_json.svalue1 == '20' %}
"HeatedIdle"
{% elif value_json.svalue1 == '30' %}
"Brewing"
{% elif value_json.svalue1 == '40' %}
"Error"
{% else %}
"Error"
{% endif %}"
options:
- "Off"
- "HeatingUp"
- "HeatedIdle"
- "Brewing"
- "Error"