Skip to content

Instantly share code, notes, and snippets.

@kmdm
Last active August 22, 2022 09:30
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmdm/29f740e5f36036fb23daba8f2109c359 to your computer and use it in GitHub Desktop.
Save kmdm/29f740e5f36036fb23daba8f2109c359 to your computer and use it in GitHub Desktop.
Home assistant and Mitsubishi via https://github.com/SwiCago/HeatPump
# Assumes you have a topic structure like: heatpump/<room> and heatpump/<room>/set
# E.g. heatpump/bedroom, heatpump/bedroom/set, heatpump/office, heatpump/office/set
#
# Configure the MQTT HVAC climate platforms (Example for master bedroom, office and nursery. Change to suit.):
climate:
- <<: &mitsu_platform
platform: mqtt
modes:
- "off"
- heat
- dry
- cool
- fan_only
- auto
fan_modes:
- AUTO
- QUIET
- "1"
- "2"
- "3"
- "4"
swing_modes:
- AUTO
- "1"
- "2"
- "3"
- "4"
- "5"
- SWING
current_temperature_template: "{{ value_json.roomTemperature }}"
temperature_state_template: "{{ value_json.temperature }}"
swing_mode_state_template: "{{ value_json.vane }}"
fan_mode_state_template: "{{ value_json.fan }}"
mode_state_template: >
{% if value_json.power == "OFF" %}
off
{% elif value_json.mode == "FAN" %}
fan_only
{% else %}
{{ value_json.mode|lower }}
{% endif %}
- <<: *mitsu_platform
name: "Office A/C"
current_temperature_topic: "heatpump/office/status"
temperature_command_topic: "heatpump/office/_set/temperature"
temperature_state_topic: "heatpump/office"
swing_mode_command_topic: "heatpump/office/_set/vane"
swing_mode_state_topic: "heatpump/office"
fan_mode_command_topic: "heatpump/office/_set/fan"
fan_mode_state_topic: "heatpump/office"
mode_command_topic: "heatpump/office/_set/mode"
mode_state_topic: "heatpump/office"
- <<: *mitsu_platform
name: "Master A/C"
current_temperature_topic: "heatpump/master/status"
temperature_command_topic: "heatpump/master/_set/temperature"
temperature_state_topic: "heatpump/master"
swing_mode_command_topic: "heatpump/master/_set/vane"
swing_mode_state_topic: "heatpump/master"
fan_mode_command_topic: "heatpump/master/_set/fan"
fan_mode_state_topic: "heatpump/master"
mode_command_topic: "heatpump/master/_set/mode"
mode_state_topic: "heatpump/master"
- <<: *mitsu_platform
name: "Nursery A/C"
current_temperature_topic: "heatpump/nursery/status"
temperature_command_topic: "heatpump/nursery/_set/temperature"
temperature_state_topic: "heatpump/nursery"
swing_mode_command_topic: "heatpump/nursery/_set/vane"
swing_mode_state_topic: "heatpump/nursery"
fan_mode_command_topic: "heatpump/nursery/_set/fan"
fan_mode_state_topic: "heatpump/nursery"
mode_command_topic: "heatpump/nursery/_set/mode"
mode_state_topic: "heatpump/nursery"
# MQTT HVAC uses individual command topics but HeatPump does not
# so use an automation to push the commands to the HP (only one automation needed due to wildcards):
alias: 'Redirect all MQTT HVAC set commands to the heatpumps'
trigger:
- platform: mqtt
topic: heatpump/+/_set/+
action:
- service: mqtt.publish
data_template:
topic: '{{ "heatpump/" + trigger.topic.split("/")[1] + "/set" }}'
payload: >
{% if trigger.topic.split("/")[-1] == "mode" %}
{% if trigger.payload|upper == "OFF" %}
{"power":"OFF"}
{% elif trigger.payload == "fan_only" %}
{"power":"ON","mode":"FAN"}
{% else %}
{{ "{\"power\":\"ON\",\"mode\":"|safe + trigger.payload|upper|tojson + "}" }}
{% endif %}
{% else %}
{{ "{" + trigger.topic.split("/")[-1]|tojson + ":" + trigger.payload|tojson + "}" }}
{% endif %}
@fernmac2
Copy link

I finally got it working without the component, using your code (thank you so much).
I only have an issue: the on command does not work, although if I click the hot or cold, the a/c goes to on. All other buttons work fine and I can turn it off, any suggestion?

@JayRama
Copy link

JayRama commented Jan 8, 2020

I have the same issue as above - did you find a solution @fernmac2 ?

@fernmac2
Copy link

fernmac2 commented Jan 8, 2020 via email

@d4hines
Copy link

d4hines commented Feb 13, 2020

Hi! This seems to be working, but there's just one issue: the data coming in is in Celsius, but I'd like to display it in Fahrenheit. Currently, Hassio is showing the Celsius temperature but the units are wrong (shows °F). Any ideas?

@ajobbins
Copy link

Hi! This seems to be working, but there's just one issue: the data coming in is in Celsius, but I'd like to display it in Fahrenheit. Currently, Hassio is showing the Celsius temperature but the units are wrong (shows °F). Any ideas?

Assume this will be because your HA system is set to Imperial, but the sensor value returned is just a raw number without the context of a unit of measurement. Can you try converting the value returned in the json from C to F in the value template?
e.g.

{{((value_json.roomTemperature * 9 / 5)+ 32)|round(1)}}
{{((value_json.temperature * 9 / 5)+ 32)|round(1)}}

@d4hines
Copy link

d4hines commented Feb 14, 2020

@ajobbins, This worked, but I lost the slider:
image

@CameronS884
Copy link

CameronS884 commented Jun 1, 2020

Thanks for this. I've got it going again which is great. Haven't had it working since compatibility broke last year sometime. Seems to be a lot of lag that wasn't there with the custom component. Not sure where that's coming from, but not a big issue. I also made some slight modifications to remove the "room" part of the topic so I didn't have to update my sketch.

@ajobbins, This worked, but I lost the slider:
image

I know this was a while back, but I'd say that you might need to adjust the "max_temp" config option in the MQTT HVAC integration. The default seems to be 35 which you can check in the developers -> states section.

@Nebukadneza
Copy link

Am i mistaken in that current HASS versions don’t allow wildcards in MQTT triggers anymore? For a single AC, it’s feasible to add triggers for the precise individual heatpump/<device>/_set/<parameter> topics, but for larger deployments this will likely be too arduous. Does anyone have a nicer idea for a fix?

@kmdm
Copy link
Author

kmdm commented May 2, 2022

I no longer have these units due to moving but if that's the case it sounds more like a regression and I'd open a bug report.

Unless you see an issue/change that says this was intentionally removed/changed.

@kmdm
Copy link
Author

kmdm commented May 2, 2022

If I was to set this up now, I would probably use one of the following which both support the MQTT climate integration natively:

https://github.com/unixko/MitsuCon

https://github.com/geoffdavis/esphome-mitsubishiheatpump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment