HI all, im having difficulties with publishing mqtt state to an offline device in zigbee2mqtt
HA Supervised, latest core
Z2m Edge latest version
it is a voltage and current counter that measures a gasoline generator powered on only when generator is working. when generator is shut down it is offline and remembers its last state and stays offline.
I managed to make a script when no updates are being sent for 1 minute it calls a mqtt.publish service with json
this way i know that generator is offline (because i use automatic ignition when power failure)
- alias: Power turn off generator 1
trigger:
- platform: state
entity_id: sensor.generator_voltage
for: "00:01:30"
action:
- service: notify.telegram_id_1
data:
message: |
{{"\U0001f50c"}} Generator turn off
- service: mqtt.publish
data:
topic: zigbee2mqtt/CounterGenerator
payload: >-
{
"current_l2": 0,
"energy_l2": 16,
"frequency_l2": 0,
"l1": 22,
"l2": 0,
"l3": 70896,
"last_seen": "2023-02-09T10:23:20.684Z",
"linkquality": 164,
"power_factor_l2": 1,
"power_l2": 0,
"temperature_l1": 22,
"voltage_l2": 0
}
in my dashboard it has a normal view as expected, mqtt explorer shows that it is 0 voltage etc
But zigbee2mqtt device state stays the same it was last measured (despite the publish action, so the params are changed only in mqtt broker)
that would be non critical if it was stable, but i sometimes get a flash message with last volts on mqtt and an automated message that generator is off by resetting voltage to 0 (device is not being powered on as well as generator did not start up but notification comes to me beacause the automation did its job)
So the question is : can i change the last measured voltage, in Z2M with and offline device? i tried publising to set topic with various payloads but that didnt take effect
zigbee2mqtt/CounterGenerator/set
zigbee2mqtt/CounterGenerator/voltage_l2
zigbee2mqtt/CounterGenerator/voltage_l2/set
i just get a new subtopic under device topic with no change that i want