hass: frequently enforce state of heater and fyrtur

This commit is contained in:
Ingolf Wagner 2020-11-05 00:23:44 +01:00
parent f5a5da5314
commit 599a889e2c
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
2 changed files with 179 additions and 155 deletions

View file

@ -63,6 +63,14 @@ in {
input_boolean.situation_toggle.icon = "mdi:toggle-switch"; input_boolean.situation_toggle.icon = "mdi:toggle-switch";
input_boolean.printer_toggle.icon = "mdi:toggle-switch"; input_boolean.printer_toggle.icon = "mdi:toggle-switch";
input_boolean.windows_up.icon = "mdi:toggle-switch";
# heater scenes
input_select.heater_state = {
#icon = "mdi:brightness-auto";
options = [ "off" "on1" "on2" ];
};
automation = [ automation = [
{ {
@ -178,203 +186,122 @@ in {
}; };
}; };
} }
# window roles # window roles
{ {
alias = "windows down in the evening"; alias = "windows state = down in the evening";
trigger = [{ trigger = [{
platform = "sun"; platform = "sun";
event = "sunset"; event = "sunset";
offset = "+00:01:00"; # 10 min after sunset offset = "+00:01:00"; # 10 min after sunset
}]; }];
action = [ action = [{
{ service = "input_select.select_option";
service = "mqtt.publish"; data = {
data_template = { entity_id = "input_select.windows_up";
topic = "zigbee2mqtt/fyrtur1/set"; # office option = "off";
payload_template = ''{"position":"15"}'';
}; };
}];
} }
{ {
service = "mqtt.publish"; alias = "windows state = up in the morning";
data_template = {
topic = "zigbee2mqtt/fyrtur2/set"; # office
payload_template = ''{"position":"15"}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/fyrtur3/set";
payload_template = ''{"position":"21"}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/fyrtur4/set";
payload_template = ''{"position":"21"}'';
};
}
];
}
{
alias = "windows up in the morning";
trigger = [{ trigger = [{
platform = "time"; platform = "time";
at = "09:00:00"; at = "09:00:00";
}]; }];
action = [ action = [{
{ service = "input_select.select_option";
service = "mqtt.publish"; data = {
data_template = { entity_id = "input_select.windows_up";
topic = "zigbee2mqtt/fyrtur1/set"; option = "on";
payload_template = ''{"position":"90"}'';
}; };
}];
} }
{ {
service = "mqtt.publish"; alias = "enforce window_up state";
data_template = { trigger = [
topic = "zigbee2mqtt/fyrtur3/set"; {
payload_template = ''{"position":"99"}''; platform = "time_pattern";
}; minutes = "/5"; # every 5 minutes
} }
{ {
service = "mqtt.publish"; platform = "state";
data_template = { entity_id = "input_boolean.windows_up";
topic = "zigbee2mqtt/fyrtur4/set";
payload_template = ''{"position":"99"}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/fyrtur2/set";
payload_template = ''{"position":"90"}'';
};
} }
]; ];
action = [{
service = "script.turn_on";
data_template.entity_id = ''
{% if is_state('input_boolean.windows_up','on') -%}
script.fyrtur_up
{%- else -%}
script.fyrtur_down
{%- endif %}
'';
}];
} }
# heater # heater
{ {
alias = "heater on in the morning"; alias = "heater state = on1 in the morning";
trigger = [{ trigger = [{
platform = "time"; platform = "time";
at = "09:00:00"; at = "09:00:00";
}]; }];
action = [ action = [{
{ service = "input_select.select_option";
service = "mqtt.publish"; data = {
data_template = { entity_id = "input_select.heater_state";
topic = "zigbee2mqtt/heater1/set"; # office option = "on1";
payload_template =
''{"system_mode":"auto","current_heating_setpoint":28.0}'';
}; };
}];
} }
{ {
service = "mqtt.publish"; alias = "heater state = on2 in the early evening";
data_template = {
topic = "zigbee2mqtt/heater2/set"; # office
payload_template =
''{"system_mode":"auto","current_heating_setpoint":28.0}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater3/set"; # bed room
payload_template =
''{"system_mode":"auto","current_heating_setpoint":19.0}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater4/set"; # storage room
payload_template =
''{"system_mode":"auto","current_heating_setpoint":19.0}'';
};
}
];
}
{
alias = "heater up in the early evening";
trigger = [{ trigger = [{
platform = "time"; platform = "time";
at = "19:45:00"; at = "19:45:00";
}]; }];
action = [ action = [{
{ service = "input_select.select_option";
service = "mqtt.publish"; data = {
data_template = { entity_id = "input_select.heater_state";
topic = "zigbee2mqtt/heater1/set"; # office option = "on2";
payload_template =
''{"system_mode":"auto","current_heating_setpoint":28.0}'';
}; };
}];
} }
{ {
service = "mqtt.publish"; alias = "heater state = off in the evening";
data_template = {
topic = "zigbee2mqtt/heater2/set"; # office
payload_template =
''{"system_mode":"auto","current_heating_setpoint":28.0}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater3/set"; # bed room
payload_template =
''{"system_mode":"auto","current_heating_setpoint":28.0}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater4/set"; # storage room
payload_template =
''{"system_mode":"auto","current_heating_setpoint":19.0}'';
};
}
];
}
{
alias = "heater off in the evening";
trigger = [{ trigger = [{
platform = "time"; platform = "time";
at = "23:00:00"; at = "23:30:00";
}]; }];
action = [ action = [{
{ service = "input_select.select_option";
service = "mqtt.publish"; data = {
data_template = { entity_id = "input_select.heater_state";
topic = "zigbee2mqtt/heater1/set"; # office option = "off";
payload_template = ''{"system_mode":"off"}'';
}; };
}];
} }
{ {
service = "mqtt.publish"; alias = "enforce heater state";
data_template = { trigger = [
topic = "zigbee2mqtt/heater2/set"; # office {
payload_template = ''{"system_mode":"off"}''; platform = "time_pattern";
}; minutes = "/5"; # every 5 minutes
} }
{ {
service = "mqtt.publish"; platform = "state";
data_template = { entity_id = "input_select.heater_state";
topic = "zigbee2mqtt/heater3/set"; # bed room
payload_template = ''{"system_mode":"off"}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater4/set"; # storage room
payload_template = ''{"system_mode":"off"}'';
};
} }
]; ];
action = [{
service = "script.turn_on";
data_template.entity_id =
"script.heater_{{ states('input_select.heater_state') }}";
}];
} }
]; ];
group = let group = let
@ -429,6 +356,100 @@ in {
}; };
script = let
# delay in seconds
delay = 2;
heater_on = heater: temperatur: {
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/${heater}/set"; # office
payload_template = ''
{"system_mode":"auto","current_heating_setpoint":${
toString temperatur
}}'';
};
};
heater_off = heater: {
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/${heater}/set"; # office
payload_template = ''{"system_mode":"off"}'';
};
};
hot = 28;
cold = 19;
fyrtur_command = device: position: {
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/${device}/set";
payload_template = ''{"position":"${toString position}"}'';
};
};
in {
heater_off = {
sequence = [
(heater_off "heater1") # office
{ delay = delay; }
(heater_off "heater2") # office
{ delay = delay; }
(heater_off "heater3") # bed room
{ delay = delay; }
(heater_off "heater4") # storage room
];
};
heater_on1 = {
sequence = [
(heater_on "heater1" hot) # office
{ delay = delay; }
(heater_on "heater2" hot) # office
{ delay = delay; }
(heater_on "heater3" cold) # bed room
{ delay = delay; }
(heater_on "heater4" cold) # storage room
];
};
heater_on2 = {
sequence = [
(heater_on "heater1" hot) # office
{ delay = delay; }
(heater_on "heater2" hot) # office
{ delay = delay; }
(heater_on "heater3" hot) # bed room
{ delay = delay; }
(heater_on "heater4" cold) # storage room
];
};
fyrtur_up = {
sequence = [
(fyrtur_command "fyrtur1" 90)
{ delay = delay; }
(fyrtur_command "fyrtur2" 90)
{ delay = delay; }
(fyrtur_command "fyrtur3" 90)
{ delay = delay; }
(fyrtur_command "fyrtur4" 99)
];
};
fyrtur_down = {
sequence = [
(fyrtur_command "fyrtur1" 15)
{ delay = delay; }
(fyrtur_command "fyrtur2" 15)
{ delay = delay; }
(fyrtur_command "fyrtur3" 21)
{ delay = delay; }
(fyrtur_command "fyrtur4" 21)
];
};
};
}; };
services.home-assistant = { services.home-assistant = {

View file

@ -14,18 +14,21 @@ let
#groups = [ "living_room" ]; #groups = [ "living_room" ];
states.single = "input_boolean.situation_toggle"; states.single = "input_boolean.situation_toggle";
states.hold = "input_boolean.printer_toggle"; states.hold = "input_boolean.printer_toggle";
states.double = "input_boolean.windows_up";
}; };
"button_2" = { "button_2" = {
id = "0x00158d0002b04f09"; id = "0x00158d0002b04f09";
#groups = [ "bed_room" ]; #groups = [ "bed_room" ];
states.single = "input_boolean.situation_toggle"; states.single = "input_boolean.situation_toggle";
states.hold = "input_boolean.printer_toggle"; states.hold = "input_boolean.printer_toggle";
states.double = "input_boolean.windows_up";
}; };
"button_3" = { "button_3" = {
id = "0x00158d0002b00e04"; id = "0x00158d0002b00e04";
#groups = [ "bed_room" ]; #groups = [ "bed_room" ];
states.single = "input_boolean.situation_toggle"; states.single = "input_boolean.situation_toggle";
states.hold = "input_boolean.printer_toggle"; states.hold = "input_boolean.printer_toggle";
states.double = "input_boolean.windows_up";
}; };
}; };