testing
This commit is contained in:
@@ -12,10 +12,57 @@ let
|
|||||||
|
|
||||||
yamlFormat = pkgs.formats.yaml { };
|
yamlFormat = pkgs.formats.yaml { };
|
||||||
|
|
||||||
mkLightswitchAutomation = name: lscfg:
|
mkLightswitchAutomation = name: lscfg: {
|
||||||
# Use explicit ordering to ensure proper YAML structure
|
id = lscfg.id;
|
||||||
listToAttrs [
|
alias = lscfg.alias;
|
||||||
(nameValuePair "actions" [
|
description = lscfg.description;
|
||||||
|
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
conditions = [];
|
||||||
|
|
||||||
|
actions = [
|
||||||
{
|
{
|
||||||
choose = [
|
choose = [
|
||||||
{
|
{
|
||||||
@@ -108,56 +155,11 @@ let
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
])
|
|
||||||
(nameValuePair "alias" lscfg.alias)
|
|
||||||
(nameValuePair "conditions" [])
|
|
||||||
(nameValuePair "description" lscfg.description)
|
|
||||||
(nameValuePair "id" (toString lscfg.id))
|
|
||||||
(nameValuePair "mode" "single")
|
|
||||||
(nameValuePair "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";
|
|
||||||
}
|
|
||||||
])
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
mode = "single";
|
||||||
|
};
|
||||||
|
|
||||||
# Generate all automations as list
|
# Generate all automations as list
|
||||||
lightswitchAutomations = mapAttrsToList mkLightswitchAutomation cfg.lightswitch;
|
lightswitchAutomations = mapAttrsToList mkLightswitchAutomation cfg.lightswitch;
|
||||||
in
|
in
|
||||||
|
|||||||
Reference in New Issue
Block a user