Hi @123 !
My code for MQTT Climate use tasmota IR (ESP8266)
climate:
- platform: mqtt
name: Office
unique_id: '1'
qos: 1
precision: 1.0
retain: true
modes:
- "cool"
- "auto"
- "dry"
- "fan_only"
- "off"
fan_modes:
- "low"
- "auto"
- "max"
- "high"
- "medium"
swing_modes:
- "auto"
- "off"
min_temp: 18
max_temp: 32
payload_on: 'on'
payload_off: 'off'
mode_command_topic: 'ir/office/mode'
mode_state_topic: 'tele/ir/RESULT'
mode_state_template: '{{ value_json["IrReceived"]["IRHVAC"]["Mode"] | lower }}'
fan_mode_command_topic: 'ir/office/fan'
fan_mode_state_topic: 'tele/ir/RESULT'
fan_mode_state_template: '{{ value_json["IrReceived"]["IRHVAC"]["FanSpeed"] | lower }}'
temperature_command_topic: 'ir/office/temp'
temperature_state_topic: 'tele/ir/RESULT'
temperature_state_template: '{{ value_json["IrReceived"]["IRHVAC"]["Temp"] }}'
swing_mode_command_topic: 'ir/office/swing'
swing_mode_state_topic: 'tele/ir/RESULT'
swing_mode_state_template: '{{ value_json["IrReceived"]["IRHVAC"]["SwingV"] | lower }}'
and 4 automations
- alias: hvac_mode controller
trigger:
platform: mqtt
topic: ir/office/mode
condition:
condition: numeric_state
entity_id: climate.office
value_template: '{{ state.attributes.temperature }} '
above: 18
below: 32
action:
- service: mqtt.publish
data_template:
topic: 'cmnd/ir/IRhvac'
payload: >
{% if trigger.payload == "off" %}
{"Protocol":"DAIKIN216","power":"off", "Mode":"{{states('climate.office')}}","FanSpeed":"{{ state_attr('climate.office', 'fan_mode') }}","Temp":{{ state_attr('climate.office', 'temperature')}} }
{% else %}
{"Protocol":"DAIKIN216", "Power":"on","Mode": "{{trigger.payload}}","FanSpeed":"{{ state_attr('climate.office','fan_mode')}}","Temp":{{ state_attr('climate.office', 'temperature')}} }
{% endif %}
- alias: hvac_temp controller
trigger:
platform: mqtt
topic: ir/office/temp
condition:
condition: numeric_state
entity_id: climate.office
value_template: '{{ state.attributes.temperature }} '
above: 18
below: 32
action:
- service: mqtt.publish
data_template:
topic: 'cmnd/ir/IRhvac'
payload: >
{"Protocol":"DAIKIN216","Power":"on","Mode":"{{states('climate.office')}}","FanSpeed":"{{state_attr('climate.office','fan_mode')}}","SwingV":"{{state_attr('climate.office','swing_mode')}}","Temp": "{{trigger.payload}}" }
- alias: hvac_fan controller
trigger:
platform: mqtt
topic: ir/office/fan
condition:
condition: numeric_state
entity_id: climate.office
value_template: '{{ state.attributes.temperature }} '
above: 18
below: 32
action:
- service: mqtt.publish
data_template:
topic: 'cmnd/ir/IRhvac'
payload: >
{"Protocol":"DAIKIN216","Power":"on","Mode":"{{states('climate.office')}}","FanSpeed":"{{trigger.payload}}","SwingV":"{{state_attr('climate.office','swing_mode')}}","Temp": {{ state_attr('climate.office', 'temperature')}} }
- alias: hvac_swing controller
trigger:
platform: mqtt
topic: ir/office/swing
condition:
condition: numeric_state
entity_id: climate.office
value_template: '{{ state.attributes.temperature }} '
above: 18
below: 32
action:
- service: mqtt.publish
data_template:
topic: 'cmnd/ir/IRhvac'
payload: >
{"Protocol":"DAIKIN216","Power":"on","Mode":"{{states('climate.office')}}","FanSpeed":"{{state_attr('climate.office','fan_mode')}}", "SwingV":{{trigger.payload}},"Temp": {{ state_attr('climate.office', 'temperature')}} }
These codes work, but when my homeassistant restart, the state of climate is not preset.
hvac_modes: cool, auto, dry, fan_only, off
min_temp: 18
max_temp: 32
target_temp_step: 1
fan_modes: low, auto, max, high, medium
swing_modes: auto, off
current_temperature: null
temperature: null
fan_mode: null
swing_mode: null
friendly_name: Office
supported_features: 41
Can you help me fix or improve this code?
(Sorry for my English)