# - service: mqtt.publish
# data:
# topic: "hasp/displ_entrance/command/p[4].b[5].txt"
# payload_template: '" {{ states( sensor.multisensor_bedroom_air_temperature) | float | round(0) }}°"'
this is the code I have, however it broke the rest of the code (it’s very long but simple):
##############################################################################
# Automations for handling climate controls on page 4
automation:
# Set font and text labels for scene buttons on device connection
- alias: hasp_displ_entrance_p4alternative_HVACInit
trigger:
- platform: state
entity_id: "binary_sensor.displ_entrance_connected"
to: "on"
- platform: homeassistant
event: start
action:
- service: mqtt.publish
data:
topic: "hasp/displ_entrance/command/json"
payload_template: >-
["p[4].b[5].font=7",
"p[4].b[7].font=7",
"p[4].b[6].font=8",
"p[4].b[8].font=8",
"p[4].b[9].font=7",
"p[4].b[11].font=7",
"p[4].b[10].font=7",
"p[4].b[12].font=7"]
- service: mqtt.publish
data:
topic: "hasp/displ_entrance/command/p[4].b[7].txt"
payload_template: '"{{ states("climate.ac_bedroom")|replace("heat_cool","")|replace("fan_only","")|replace("dry","")|replace("cool","")|replace("heat","")|replace("off","")|title }} {{ state_attr("climate.ac_bedroom", "temperature") | int }}°"'
# - service: mqtt.publish
# data:
# topic: "hasp/displ_entrance/command/p[4].b[5].txt"
# payload_template: '" {{ states( sensor.multisensor_bedroom_air_temperature) | float | round(0) }}°"'
- service: mqtt.publish
data:
topic: "hasp/displ_entrance/command/p[4].b[6].txt"
payload_template: '""'
- service: mqtt.publish
data:
topic: "hasp/displ_entrance/command/p[4].b[8].txt"
payload_template: '""'
- service: mqtt.publish
data:
topic: "hasp/displ_entrance/command/p[4].b[11].txt"
payload_template: '" AVG."'
- service: mqtt.publish
data:
topic: "hasp/displ_entrance/command/p[4].b[9].txt"
payload_template: '" EXT."'
- service: mqtt.publish
data:
topic: "hasp/displ_entrance/command/p[4].b[10].txt"
payload_template: '"{{ state_attr("sensor.outside_average_temperature", "mean") | float | round(0) }}°"'
- service: mqtt.publish
data:
topic: "hasp/displ_entrance/command/p[4].b[12].txt"
payload_template: '"{{ state_attr("sensor.home_average_temerpature", "mean") | float | round(0) }}°"'
- alias: hasp_displ_entrance_p4alternative_UpdateHVACMode1
trigger:
- platform: state
entity_id: "climate.bedroom"
action:
- service: mqtt.publish
data:
topic: "hasp/displ_entrance/command/p[4].b[7].txt"
payload_template: '"{{ states("climate.ac_bedroom")|replace("heat_cool","")|replace("fan_only","")|replace("dry","")|replace("cool","")|replace("heat","")|replace("off","")|title }} {{ state_attr("climate.ac_bedroom", "temperature") | int }}°"'
# Catch either of the "mode" buttons, iterate through the list of supported modes, and
# select the next one in the list or loop back to the beginning if it's the last item
- alias: hasp_displ_entrance_p4alternative_CycleHVACMode1
trigger:
- platform: mqtt
topic: "hasp/displ_entrance/state/p[4].b[7]"
payload: "ON"
action:
- service: climate.set_hvac_mode
entity_id: "climate.ac_bedroom"
data_template:
hvac_mode: >-
{% for mode in state_attr("climate.ac_bedroom", "hvac_modes") %}
{% if mode == states("climate.ac_bedroom") %}
{% if loop.last %}
{{ state_attr("climate.ac_bedroom", "hvac_modes")[0] }}
{% else %}
{{ state_attr("climate.ac_bedroom", "hvac_modes")[loop.index] }}
{% endif %}
{% endif %}
{% endfor %}
# Display current HVAC temp on HASP when updated in Home Assistant
- alias: hasp_displ_entrance_p4alternative_UpdateHVACTemp1
trigger:
platform: state
entity_id: "climate.ac_bedroom"
condition:
condition: template
value_template: '{{ trigger.from_state and trigger.to_state.attributes.current_temperature != trigger.from_state.attributes.current_temperature }}'
action:
- service: mqtt.publish
data:
topic: "hasp/displ_entrance/command/p[4].b[5].txt"
payload_template: '" {{ state_attr("climate.ac_bedroom", "current_temperature") | int}}°"'
# Display HVAC temp set point on HASP when updated in Home Assistant
- alias: hasp_displ_entrance_p4alternative_UpdateHVACTempHigh1
trigger:
platform: state
entity_id: "climate.ac_bedroom"
condition:
condition: template
value_template: '{{ trigger.from_state and trigger.to_state.attributes.temperature != trigger.from_state.attributes.temperature }}'
action:
- service: mqtt.publish
data:
topic: "hasp/displ_entrance/command/p[4].b[7].txt"
payload_template: '"{{ states("climate.ac_bedroom")|replace("heat_cool","")|replace("fan_only","")|replace("dry","")|replace("cool","")|replace("heat","")|replace("off","")|title }} {{ state_attr("climate.ac_bedroom", "temperature") | int }}°"'
# Increment HVAC temp set point when p[4].b[6] is pressed
- alias: hasp_displ_entrance_p4alternative_SetHVACTempPlus1
trigger:
- platform: mqtt
topic: "hasp/displ_entrance/state/p[4].b[6]"
payload: "ON"
action:
- service: climate.set_temperature
entity_id: "climate.ac_bedroom"
data_template:
temperature: '{{ state_attr("climate.ac_bedroom", "temperature") + 1 | int}}'
# Decrement HVAC temp set point when p[4].b[8] is pressed
- alias: hasp_displ_entrance_p4alternative_SetHVACTempMinus1
trigger:
- platform: mqtt
topic: "hasp/displ_entrance/state/p[4].b[8]"
payload: "ON"
action:
- service: climate.set_temperature
entity_id: "climate.ac_bedroom"
data_template:
temperature: '{{ state_attr("climate.ac_bedroom", "temperature") - 1 | int}}'
# Turn off HVAC when p[4].b[5] is pressed
- alias: hasp_displ_entrance_p4alternative_SetHVACOff1
trigger:
- platform: mqtt
topic: "hasp/displ_entrance/state/p[4].b[5]"
payload: "ON"
action:
- service: climate.set_hvac_mode
entity_id: "climate.ac_bedroom"
data_template:
hvac_mode: "off"