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.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 = [
{
@ -178,203 +186,122 @@ in {
};
};
}
# window roles
{
alias = "windows down in the evening";
alias = "windows state = down in the evening";
trigger = [{
platform = "sun";
event = "sunset";
offset = "+00:01:00"; # 10 min after sunset
}];
action = [
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/fyrtur1/set"; # office
payload_template = ''{"position":"15"}'';
action = [{
service = "input_select.select_option";
data = {
entity_id = "input_select.windows_up";
option = "off";
};
}];
}
{
service = "mqtt.publish";
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";
alias = "windows state = up in the morning";
trigger = [{
platform = "time";
at = "09:00:00";
}];
action = [
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/fyrtur1/set";
payload_template = ''{"position":"90"}'';
action = [{
service = "input_select.select_option";
data = {
entity_id = "input_select.windows_up";
option = "on";
};
}];
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/fyrtur3/set";
payload_template = ''{"position":"99"}'';
};
alias = "enforce window_up state";
trigger = [
{
platform = "time_pattern";
minutes = "/5"; # every 5 minutes
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/fyrtur4/set";
payload_template = ''{"position":"99"}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/fyrtur2/set";
payload_template = ''{"position":"90"}'';
};
platform = "state";
entity_id = "input_boolean.windows_up";
}
];
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
{
alias = "heater on in the morning";
alias = "heater state = on1 in the morning";
trigger = [{
platform = "time";
at = "09:00:00";
}];
action = [
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater1/set"; # office
payload_template =
''{"system_mode":"auto","current_heating_setpoint":28.0}'';
action = [{
service = "input_select.select_option";
data = {
entity_id = "input_select.heater_state";
option = "on1";
};
}];
}
{
service = "mqtt.publish";
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";
alias = "heater state = on2 in the early evening";
trigger = [{
platform = "time";
at = "19:45:00";
}];
action = [
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater1/set"; # office
payload_template =
''{"system_mode":"auto","current_heating_setpoint":28.0}'';
action = [{
service = "input_select.select_option";
data = {
entity_id = "input_select.heater_state";
option = "on2";
};
}];
}
{
service = "mqtt.publish";
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";
alias = "heater state = off in the evening";
trigger = [{
platform = "time";
at = "23:00:00";
at = "23:30:00";
}];
action = [
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater1/set"; # office
payload_template = ''{"system_mode":"off"}'';
action = [{
service = "input_select.select_option";
data = {
entity_id = "input_select.heater_state";
option = "off";
};
}];
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater2/set"; # office
payload_template = ''{"system_mode":"off"}'';
};
alias = "enforce heater state";
trigger = [
{
platform = "time_pattern";
minutes = "/5"; # every 5 minutes
}
{
service = "mqtt.publish";
data_template = {
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"}'';
};
platform = "state";
entity_id = "input_select.heater_state";
}
];
action = [{
service = "script.turn_on";
data_template.entity_id =
"script.heater_{{ states('input_select.heater_state') }}";
}];
}
];
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 = {

View file

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