I’d like to be able to define the payload for the state topic, like the availability and command topics.
My alarm panel’s states are reported as integer values and they must be converted into string values:
- ‘disarmed’
- ‘armed_home’
- ‘armed_away’
- ‘pending’
- ‘triggered’
To address this need, I modified the MQTT Alarm Panel platform; my customized version supports a state_template
parameter. Here is an example of how it is used in configuration.yaml
:
alarm_control_panel:
- platform: mqtt_alarm
name: Security System
state_topic: "premise/home/securitysystem/securitystate"
state_template: >-
{% set values = { '0': 'armed_away', '1':'disarmed', '2':'armed_home', '3':'triggered'} %}
{{ values[value] if value in values.keys() else 'disarmed' }}
command_topic: "premise/command/home/securitysystem/securityaction"
payload_disarm: 1
payload_arm_home: 2
payload_arm_away: 0
code_command_topic: "premise/command/home/securitysystem/disarmcode"
code: !secret alarm_panel_code
retain: false
Let me know if you are interested and I’ll post the modified version.
Hi
Thank you.
I solved the problem by setting up automations that receive the state payloads in one topic and retransmit them in another topic with the correct payloads. Not my idea though. It works and was easy to setup.
I know it is an old post, would you mind posting your solution? Thank you
Hi
I don’t use that configuration since I switched to using the very nice Visonic custom integration by Dave. More info here: GitHub - davesmeghead/visonic: Visonic Custom Component for integration with Home Assistant
Basically, I set up automations with MQTT as trigger and mqtt.publish as action. When a certain message is received, post a new message in another topic.