I have a Way acting like a z-wave hub and like to look at implementing dimmer to HASS.
Z-way have the option to receive 0-99 and on/off but only sends out 0-99 as feedback.
So my question is, how can I use state template to control the status of the switch. Like to turn it off at 0 and on beetween 1-99.
Its hard to suggest anything without being certain of the messages. Please paste the messages being sent and received using something like mosquitto_sub see https://www.home-assistant.io/docs/mqtt/testing/
I’m jusing HASS, didn’t quiet understand how to add this message being sent function. But I can try to explain.
This is a dimmer from Z-way and I use a MQTT program to se what values being sent/received:
z-way -> HASS: 0-99
HASS -> 0-99, but z-way also se “on” and “off” from HASS, but do not send this when pressing on/off in z-way interface.
The reason for wanting to send the on or off from HASS is to use the “last value” when pressing on in HASS HMI.
I did a bit of checking, and the value is a string, which you have to convert to an integer in jinja before comparing it. This seems to work - if I understand your messages correctly
Havent figured out how to fetch this data from MQTT when I’m using HASS. Can I use the Mac terminal to connect to HASS?
Here is something from my MQTTBox app, this is from when I try to turn it on from HASS:
If I send message from MQTTBox the Payload_type need to be set to: “Strings/JSON/XML/Characters”
As you can se it send value 66 then on when I press “on” in HASS. What can I do to only send “on”.
It looks like the on_command_type parameter would set this, but there is no option to not send the brightness.
It shouldn’t matter as it will just set the brightness to the level indicated by HA.
I notice though, that you have the same topic to set the brightness and the on state, which doesn’t look correct. Doesn’t your controller have different topics for that?
the topic is the same for on/off and brightness commands according to the github link. Its sort of working now, but if I set the on_command_type to brightness the switch in HA set the light to 99% and not last value.
So I tried the “last” command but then the light jumps to the value I have set but then goes back again to old value. Think this has something to do with the update of z-way isn’t fast enough before receiving the “on” value.
Maybe the “MQTT Template” component have more options. Really like to have a solid MQTT before I move everything to HASS:)