I have a mqtt payload that gets sent over to home-assistant but if i restart home-assistant the mqtt doesn’t get sent over, so i’d like to create a sensor for it if it’s on or off
so far i’ve created this…? does this look correct?
this works!!! awesome…, anyway to change the output if it’s “on”
it prints this out,
<template state alarm_control_panel.ring_alarm=disarmed; code_format=None, changed_by=None, friendly_name=Ring Alarm @ 2019-04-11T22:47:29.895275-07:00>off
How can i go about restarting the service (once) if it’s set to off?
if it reports back false (if off) and True (if on), next i’d like to create an automation to restart the service
Whatever is publishing the sensor’s state to the broker should do so using retain=true. It instructs the broker to retain (store) it. When Home Assistant restarts, it re-connects to the broker, re-subscribes to the sensor’s topic and immediately receives the retained state.
All of my MQTT sensors and binary sensors publish their state as retained messages. When Home Assistant restarts, all sensor values are received from the broker.
Don’t confuse this with retain: true in the configuration of Home Assistant’s MQTT Sensor and Binary Sensor components. I’m talking about the physical sensor device you’re using that publishes its state to the broker. That device ought to publish its state as a retained message.
Off the top of my head, no. The change you’re making doesn’t alter connections or topics. It only specifies that a message (published by the script) must now be retained by the broker.
To fix problems with MQTT, it’s helpful to use an MQTT client like MQTT Explorer. It allows you to view all your broker’s topics, each topic’s payload, and if the payload is retained by the broker.