testing
This commit is contained in:
@@ -13,151 +13,152 @@ let
|
|||||||
yamlFormat = pkgs.formats.yaml { };
|
yamlFormat = pkgs.formats.yaml { };
|
||||||
|
|
||||||
mkLightswitchAutomation = name: lscfg: {
|
mkLightswitchAutomation = name: lscfg: {
|
||||||
id = toString lscfg.id;
|
"${toString lscfg.id}" = {
|
||||||
alias = lscfg.alias;
|
alias = lscfg.alias;
|
||||||
description = lscfg.description;
|
description = lscfg.description;
|
||||||
|
|
||||||
triggers = [
|
triggers = [
|
||||||
{
|
{
|
||||||
domain = "mqtt";
|
domain = "mqtt";
|
||||||
device_id = lscfg.mqttDeviceId;
|
device_id = lscfg.mqttDeviceId;
|
||||||
type = "action";
|
type = "action";
|
||||||
subtype = "on-press";
|
subtype = "on-press";
|
||||||
trigger = "device";
|
trigger = "device";
|
||||||
id = "on press";
|
id = "on press";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
domain = "mqtt";
|
domain = "mqtt";
|
||||||
device_id = lscfg.mqttDeviceId;
|
device_id = lscfg.mqttDeviceId;
|
||||||
type = "action";
|
type = "action";
|
||||||
subtype = "off-press";
|
subtype = "off-press";
|
||||||
trigger = "device";
|
trigger = "device";
|
||||||
id = "off press";
|
id = "off press";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
domain = "mqtt";
|
domain = "mqtt";
|
||||||
device_id = lscfg.mqttDeviceId;
|
device_id = lscfg.mqttDeviceId;
|
||||||
type = "action";
|
type = "action";
|
||||||
subtype = "up-press";
|
subtype = "up-press";
|
||||||
trigger = "device";
|
trigger = "device";
|
||||||
id = "up press";
|
id = "up press";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
domain = "mqtt";
|
domain = "mqtt";
|
||||||
device_id = lscfg.mqttDeviceId;
|
device_id = lscfg.mqttDeviceId;
|
||||||
type = "action";
|
type = "action";
|
||||||
subtype = "down-press";
|
subtype = "down-press";
|
||||||
trigger = "device";
|
trigger = "device";
|
||||||
id = "down press";
|
id = "down press";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
domain = "mqtt";
|
domain = "mqtt";
|
||||||
device_id = lscfg.mqttDeviceId;
|
device_id = lscfg.mqttDeviceId;
|
||||||
type = "action";
|
type = "action";
|
||||||
subtype = "on-hold";
|
subtype = "on-hold";
|
||||||
trigger = "device";
|
trigger = "device";
|
||||||
id = "on hold";
|
id = "on hold";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
conditions = [];
|
conditions = [];
|
||||||
|
|
||||||
actions = [
|
actions = [
|
||||||
{
|
{
|
||||||
choose = [
|
choose = [
|
||||||
{
|
{
|
||||||
conditions = [
|
conditions = [
|
||||||
{
|
{
|
||||||
condition = "trigger";
|
condition = "trigger";
|
||||||
id = [ "on press" ];
|
id = [ "on press" ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
sequence = [
|
sequence = [
|
||||||
{
|
{
|
||||||
action = "light.turn_on";
|
action = "light.turn_on";
|
||||||
metadata = {};
|
metadata = {};
|
||||||
data = {
|
data = {
|
||||||
transition = lscfg.transitionTime;
|
transition = lscfg.transitionTime;
|
||||||
brightness_pct = lscfg.brightnessPercent;
|
brightness_pct = lscfg.brightnessPercent;
|
||||||
kelvin = lscfg.lightTemperature;
|
kelvin = lscfg.lightTemperature;
|
||||||
};
|
};
|
||||||
target.entity_id = [ lscfg.lightEntityId ];
|
target.entity_id = [ lscfg.lightEntityId ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
conditions = [
|
conditions = [
|
||||||
{
|
{
|
||||||
condition = "trigger";
|
condition = "trigger";
|
||||||
id = [ "off press" ];
|
id = [ "off press" ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
sequence = [
|
sequence = [
|
||||||
{
|
{
|
||||||
action = "light.turn_off";
|
action = "light.turn_off";
|
||||||
metadata = {};
|
metadata = {};
|
||||||
data.transition = lscfg.transitionTime;
|
data.transition = lscfg.transitionTime;
|
||||||
target.entity_id = [ lscfg.lightEntityId ];
|
target.entity_id = [ lscfg.lightEntityId ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
conditions = [
|
conditions = [
|
||||||
{
|
{
|
||||||
condition = "trigger";
|
condition = "trigger";
|
||||||
id = [ "up press" ];
|
id = [ "up press" ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
sequence = [
|
sequence = [
|
||||||
{
|
{
|
||||||
action = "light.turn_on";
|
action = "light.turn_on";
|
||||||
metadata = {};
|
metadata = {};
|
||||||
data.brightness_step_pct = lscfg.brightnessStepPercent;
|
data.brightness_step_pct = lscfg.brightnessStepPercent;
|
||||||
target.entity_id = lscfg.lightEntityId;
|
target.entity_id = lscfg.lightEntityId;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
conditions = [
|
conditions = [
|
||||||
{
|
{
|
||||||
condition = "trigger";
|
condition = "trigger";
|
||||||
id = [ "down press" ];
|
id = [ "down press" ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
sequence = [
|
sequence = [
|
||||||
{
|
{
|
||||||
action = "light.turn_on";
|
action = "light.turn_on";
|
||||||
metadata = {};
|
metadata = {};
|
||||||
data.brightness_step_pct = -lscfg.brightnessStepPercent;
|
data.brightness_step_pct = -lscfg.brightnessStepPercent;
|
||||||
target.entity_id = lscfg.lightEntityId;
|
target.entity_id = lscfg.lightEntityId;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
conditions = [
|
conditions = [
|
||||||
{
|
{
|
||||||
condition = "trigger";
|
condition = "trigger";
|
||||||
id = [ "on hold" ];
|
id = [ "on hold" ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
sequence = [
|
sequence = [
|
||||||
{
|
{
|
||||||
action = "light.turn_on";
|
action = "light.turn_on";
|
||||||
metadata = {};
|
metadata = {};
|
||||||
data = {
|
data = {
|
||||||
transition = 0;
|
transition = 0;
|
||||||
brightness_pct = 100;
|
brightness_pct = 100;
|
||||||
rgb_color = [ 255 38 0 ];
|
rgb_color = [ 255 38 0 ];
|
||||||
};
|
};
|
||||||
target.entity_id = [ lscfg.lightEntityId ];
|
target.entity_id = [ lscfg.lightEntityId ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
mode = "single";
|
mode = "single";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Generate all automations as list
|
# Generate all automations as list
|
||||||
|
|||||||
Reference in New Issue
Block a user