From 1abb43173e05aad3f5c9b7ac85c80ebf14749fb0 Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Wed, 19 Jun 2024 23:04:33 -0400 Subject: Control AC with bedroom temperature sensor --- hostnix/elmo/home-assistant.nix | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/hostnix/elmo/home-assistant.nix b/hostnix/elmo/home-assistant.nix index 68fa615..d97e7a1 100644 --- a/hostnix/elmo/home-assistant.nix +++ b/hostnix/elmo/home-assistant.nix @@ -61,10 +61,37 @@ brightness_mode_time_light = 3 * 60 * 60; }; + switch = [ + { + platform = "template"; + switches = { + midea_cool = { + value_template = "{{ is_state('climate.air_conditioner_1', 'cool') and state_attr('climate.air_conditioner_1', 'temperature')|float < 72 }}"; + turn_on = [ + { + service = "climate.set_temperature"; + target.entity_id = "climate.air_conditioner_1"; + data = { + hvac_mode = "cool"; + temperature = 70; + }; + } + ]; + turn_off = [ + { + service = "climate.turn_off"; + target.entity_id = "climate.air_conditioner_1"; + } + ]; + }; + }; + } + ]; + climate = [ { platform = "generic_thermostat"; - name = "Bedroom"; + name = "Bedroom Heat"; heater = "switch.thermostat_heat"; target_sensor = "sensor.bedroom_temperature"; min_cycle_duration.minutes = 2; @@ -72,6 +99,14 @@ # initial_hvac_mode = "off" keep_alive.minutes = 5; } + { + platform = "generic_thermostat"; + name = "Bedroom Cool"; + ac_mode = true; + heater = "switch.midea_cool"; + target_sensor = "sensor.bedroom_temperature"; + min_cycle_duration.minutes = 2; + } ]; # - alias: Sound machine switch @@ -421,6 +456,7 @@ }; action = [ (service "light.turn_off" "light.panel_light") + (service "climate.turn_off" "climate.bedroom_cool") ]; } -- cgit v1.3.1