Again MQTT after reboot - topics from zipato zipabox

Hi!
I own a Zipato zipabox zwave controller and I’m setting up home assistant to gradually migrate and abandon zipato.
I built my home assistant setup on rpi4, ubuntu 64bit and supervised home assistant on docker, with mqtt integration.
I activated MQTT on zipato zipabox, that correctly send attributes value, but only on attribute’s changes and without retain (and I can’t modify that)
this is one of the entity I configured as a switch:

  - platform: mqtt
    name: Luce Notte Asia
    icon: mdi:weather-night
    state_topic: zipato/zipabox/attributes/xxxxxxxx-951f-46cb-8037-3f11715ff3c0/value
    command_topic: zipato/zipabox/request/attributes/xxxxxxxx-951f-46cb-8037-3f11715ff3c0/textValue
    value_template: "{{ value_json.value }}"
    payload_on: true
    payload_off: false
    state_on: true
    state_off: false

Obviously the problem is on home assistant reboot: all my zipabox mqtt switches appear as off because they are not available…
I can request to zipabox the value sending a request to zipato/zipabox/request/attributes/uuid/getValue and zipabox reply on topic zipato/zipabox/request/attributes/53bab7a8-951f-46cb-8037-3f11715ff3c0/currentValue

How can I get this value to update my ha entity on reboot?
Scripting on state_topic is not possibile, so anyone that is able to address me to the right path?
I searched a lot on the community, but I was unable to find a solution :frowning:

1 Like

Something like this : ?

- id: '1565194745362'
  alias: Status bij opstarten HA
  trigger:
  - event: start
    platform: homeassistant
  condition: []
  action:
  - data:
      payload: ''
      topic: zipato/zipabox/request/attributes/uuid/getValue
    service: mqtt.publish

Thanks @francisp
This is was I originally thinked… But it do not works, because the reply topic to the request is zipato/zipabox/attributes/xxxxxxxx-951f-46cb-8037-3f11715ff3c0/currentValue but normally the zipabox publish the status changes on zipato/zipabox/attributes/xxxxxxxx-951f-46cb-8037-3f11715ff3c0/value

So if I define the switch with the status topic as currentValue, your solution works, but only at ha reboot and no more at every value change…
If I define the switch with the status topic as value, the switch replicate each status change… but stay unknown until a state change occur.

… Is there a way to get currentValue value and put it in the switch state? Or, best solution, change the switch status_topic with a script/templating/magic :slight_smile: ?

You could create an automation that republishes zipato/zipabox/attributes/xxxxxxxx-951f-46cb-8037-3f11715ff3c0/ currentValue to zipato/zipabox/attributes/xxxxxxxx-951f-46cb-8037-3f11715ff3c0/ value

1 Like

I’ll study on it.
I’m a newbie on home asistant and mqtt so, something is probably unknown to me… I Imagined that home hassistant was able to publish only with its own topic and not with a different topic.
I’ll study on it, thank you.
I’ll write here how it will go the story :slight_smile:

You pointed me in the right direction.

alias: MQTT GetValue Requests
description: ''
trigger:
- platform: mqtt
topic: zipato/zipabox/attributes/#
condition:
- condition: template
value_template: '{{ trigger.topic.split(''/'')[4] == ''currentValue'' }}'
action:
- service: mqtt.publish
data_template:
topic: zipato/zipabox/attributes/{{trigger.topic.split('/')[3]}}/value
payload: '{{trigger.payload}}'
mode: single

It simply works if I manually publish on a getValue topic! :+1:

Now I have to find the way to loop trough all the mqtt entities to publish on a getValue topic.

@ExTrEmE I’m also setting up home assistant to slowly move away from my Zipabox from Zipato using MQTT.
Did you manage to produce a solution for this?

I’m a novice, so far I’ve been focusing on some of the more difficult integrations (e.g. combining a z-wave switch and z-wave door sensor on my garage door to create a smart garage door). I’ve shared my working examples here.

If you have examples of Zipato specific solutions you’re willing to share, that would be much appreciated.
I’m for example still struggling with Home Assistant giving errors about my Zipabox IP trying to connect.
Login attempt or request with invalid authentication from 192.168.0.164 (192.168.0.164) (okhttp/3.7.0-SNAPSHOT) Not sure why it is giving errors because the Zipabox is publishing and reading on the MQTT server in Home Assistant without issues.

@quizzical Talking about how to recover mqtt entity after reboot, yes.
A bad solution, long to apply, but it works. I would prefer a scriptable way, with a loop or something else… but that’s it.
I simply made a script with near 80 service calls, one for each entity, as example

alias: UpdateZipatoMQTT
sequence:
  - service: mqtt.publish
    data:
      topic: >-
        zipato/zipabox/request/attributes/UUID/getValue
      payload: ''
      qos: 1

I built an automation that call that script after the home assistant rebooting process.
The script place the call, the republish automation do its job and republish it on the topic linked to the entity.
The automation is configured to run in parallel mode.

alias: MQTT ripubblica currentValue su value
description: >-
  Prende la risposte alla chiamata getValue sulla zipabox e li ripubblica sul
  topic giusto
trigger:
  - platform: mqtt
    topic: 'zipato/zipabox/attributes/#'
condition:
  - condition: template
    value_template: '{{ trigger.topic.split(''/'')[4] == ''currentValue'' }}'
action:
  - service: mqtt.publish
    data_template:
      topic: 'zipato/zipabox/attributes/{{trigger.topic.split(''/'')[3]}}/value'
      payload: '{{trigger.payload}}'
      qos: 1
mode: parallel
max: 80

No zipabox related messages on the logs.
This is my zipabox mqtt network config:

{
  "className": "com.zipato.network.mqtt.MqttNetwork",
  "password": "my_super_safe_password_defined_in_broker:)",
  "clientId": null,
  "qos": 1,
  "topicPrefix": "zipabox/",
  "name": "MQTT_Zipato",
  "broker": "tcp://my_broker_ip:1883",
  "uuid": "my_network_uuid",
  "topicBase": "zipato/",
  "username": "homeassistant",
  "tags": null,
  "order": null
}

The only thing I noticed since I enabled MQTT on zipabox1 is a more frequent self-reboot. But seems to work.
Oh!
Another thing. Using MQTT-Explorer I noticed that is some case the state is pulished as string, sometimes as boolean (damn zipato!), so I placed a check block in the value_template of entities. example:

  - platform: mqtt
    name: Luce Notte Fede
    icon: mdi:weather-night
    state_topic: zipato/zipabox/attributes/UUID/value
    command_topic: zipato/zipabox/request/attributes/SAME_UUID_AS_ABOVE/textValue
    value_template: >
      {%if value_json.value=='true'%}
        {{true}}
      {%elif value_json.value=='false'%}
        {{false}}
      {%else%}
        {{value_json.value}}
      {%endif%}
    payload_on: true
    payload_off: false
    state_on: true
    state_off: false

Probably I done it wrong… but it apparently works :slight_smile:

1 Like