test idk
This commit is contained in:
@@ -13,58 +13,10 @@ let
|
|||||||
yamlFormat = pkgs.formats.yaml { };
|
yamlFormat = pkgs.formats.yaml { };
|
||||||
|
|
||||||
mkLightswitchAutomation = name: lscfg: {
|
mkLightswitchAutomation = name: lscfg: {
|
||||||
"${toString lscfg.id}" = {
|
|
||||||
alias = lscfg.alias;
|
|
||||||
description = lscfg.description;
|
|
||||||
|
|
||||||
triggers = [
|
|
||||||
{
|
|
||||||
domain = "mqtt";
|
|
||||||
device_id = lscfg.mqttDeviceId;
|
|
||||||
type = "action";
|
|
||||||
subtype = "on-press";
|
|
||||||
trigger = "device";
|
|
||||||
id = "on press";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
domain = "mqtt";
|
|
||||||
device_id = lscfg.mqttDeviceId;
|
|
||||||
type = "action";
|
|
||||||
subtype = "off-press";
|
|
||||||
trigger = "device";
|
|
||||||
id = "off press";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
domain = "mqtt";
|
|
||||||
device_id = lscfg.mqttDeviceId;
|
|
||||||
type = "action";
|
|
||||||
subtype = "up-press";
|
|
||||||
trigger = "device";
|
|
||||||
id = "up press";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
domain = "mqtt";
|
|
||||||
device_id = lscfg.mqttDeviceId;
|
|
||||||
type = "action";
|
|
||||||
subtype = "down-press";
|
|
||||||
trigger = "device";
|
|
||||||
id = "down press";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
domain = "mqtt";
|
|
||||||
device_id = lscfg.mqttDeviceId;
|
|
||||||
type = "action";
|
|
||||||
subtype = "on-hold";
|
|
||||||
trigger = "device";
|
|
||||||
id = "on hold";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
conditions = [];
|
|
||||||
|
|
||||||
actions = [
|
actions = [
|
||||||
{
|
{
|
||||||
choose = [
|
choose = [
|
||||||
|
# On Press
|
||||||
{
|
{
|
||||||
conditions = [
|
conditions = [
|
||||||
{
|
{
|
||||||
@@ -75,16 +27,17 @@ let
|
|||||||
sequence = [
|
sequence = [
|
||||||
{
|
{
|
||||||
action = "light.turn_on";
|
action = "light.turn_on";
|
||||||
metadata = {};
|
|
||||||
data = {
|
data = {
|
||||||
transition = lscfg.transitionTime;
|
|
||||||
brightness_pct = lscfg.brightnessPercent;
|
brightness_pct = lscfg.brightnessPercent;
|
||||||
kelvin = lscfg.lightTemperature;
|
kelvin = lscfg.lightTemperature;
|
||||||
|
transition = lscfg.transitionTime;
|
||||||
};
|
};
|
||||||
|
metadata = {};
|
||||||
target.entity_id = [ lscfg.lightEntityId ];
|
target.entity_id = [ lscfg.lightEntityId ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
# Off Press
|
||||||
{
|
{
|
||||||
conditions = [
|
conditions = [
|
||||||
{
|
{
|
||||||
@@ -95,12 +48,13 @@ let
|
|||||||
sequence = [
|
sequence = [
|
||||||
{
|
{
|
||||||
action = "light.turn_off";
|
action = "light.turn_off";
|
||||||
metadata = {};
|
|
||||||
data.transition = lscfg.transitionTime;
|
data.transition = lscfg.transitionTime;
|
||||||
|
metadata = {};
|
||||||
target.entity_id = [ lscfg.lightEntityId ];
|
target.entity_id = [ lscfg.lightEntityId ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
# Up Press
|
||||||
{
|
{
|
||||||
conditions = [
|
conditions = [
|
||||||
{
|
{
|
||||||
@@ -111,12 +65,13 @@ let
|
|||||||
sequence = [
|
sequence = [
|
||||||
{
|
{
|
||||||
action = "light.turn_on";
|
action = "light.turn_on";
|
||||||
metadata = {};
|
|
||||||
data.brightness_step_pct = lscfg.brightnessStepPercent;
|
data.brightness_step_pct = lscfg.brightnessStepPercent;
|
||||||
target.entity_id = lscfg.lightEntityId;
|
metadata = {};
|
||||||
|
target.entity_id = lscfg.lightEntityId; # String, not list
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
# Down Press
|
||||||
{
|
{
|
||||||
conditions = [
|
conditions = [
|
||||||
{
|
{
|
||||||
@@ -127,12 +82,13 @@ let
|
|||||||
sequence = [
|
sequence = [
|
||||||
{
|
{
|
||||||
action = "light.turn_on";
|
action = "light.turn_on";
|
||||||
metadata = {};
|
|
||||||
data.brightness_step_pct = -lscfg.brightnessStepPercent;
|
data.brightness_step_pct = -lscfg.brightnessStepPercent;
|
||||||
target.entity_id = lscfg.lightEntityId;
|
metadata = {};
|
||||||
|
target.entity_id = lscfg.lightEntityId; # String, not list
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
# On Hold
|
||||||
{
|
{
|
||||||
conditions = [
|
conditions = [
|
||||||
{
|
{
|
||||||
@@ -143,12 +99,12 @@ let
|
|||||||
sequence = [
|
sequence = [
|
||||||
{
|
{
|
||||||
action = "light.turn_on";
|
action = "light.turn_on";
|
||||||
metadata = {};
|
|
||||||
data = {
|
data = {
|
||||||
transition = 0;
|
|
||||||
brightness_pct = 100;
|
brightness_pct = 100;
|
||||||
rgb_color = [ 255 38 0 ];
|
rgb_color = lscfg.holdRgbColor;
|
||||||
|
transition = 0;
|
||||||
};
|
};
|
||||||
|
metadata = {};
|
||||||
target.entity_id = [ lscfg.lightEntityId ];
|
target.entity_id = [ lscfg.lightEntityId ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@@ -157,8 +113,54 @@ let
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
mode = "single";
|
alias = lscfg.alias;
|
||||||
};
|
conditions = [];
|
||||||
|
description = lscfg.description;
|
||||||
|
id = lscfg.id;
|
||||||
|
mode = lscfg.mode;
|
||||||
|
|
||||||
|
triggers = [
|
||||||
|
{
|
||||||
|
device_id = lscfg.mqttDeviceId;
|
||||||
|
domain = "mqtt";
|
||||||
|
id = "on press";
|
||||||
|
subtype = "on-press";
|
||||||
|
trigger = "device";
|
||||||
|
type = "action";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
device_id = lscfg.mqttDeviceId;
|
||||||
|
domain = "mqtt";
|
||||||
|
id = "off press";
|
||||||
|
subtype = "off-press";
|
||||||
|
trigger = "device";
|
||||||
|
type = "action";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
device_id = lscfg.mqttDeviceId;
|
||||||
|
domain = "mqtt";
|
||||||
|
id = "up press";
|
||||||
|
subtype = "up-press";
|
||||||
|
trigger = "device";
|
||||||
|
type = "action";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
device_id = lscfg.mqttDeviceId;
|
||||||
|
domain = "mqtt";
|
||||||
|
id = "down press";
|
||||||
|
subtype = "down-press";
|
||||||
|
trigger = "device";
|
||||||
|
type = "action";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
device_id = lscfg.mqttDeviceId;
|
||||||
|
domain = "mqtt";
|
||||||
|
id = "on hold";
|
||||||
|
subtype = "on-hold";
|
||||||
|
trigger = "device";
|
||||||
|
type = "action";
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Generate all automations as list
|
# Generate all automations as list
|
||||||
|
|||||||
Reference in New Issue
Block a user