hass: major improvements on sensors
This commit is contained in:
parent
60f7d13fa1
commit
8103e2f9f1
4 changed files with 55 additions and 198 deletions
|
@ -22,6 +22,14 @@ in {
|
||||||
friendly_name = name;
|
friendly_name = name;
|
||||||
transition = 1;
|
transition = 1;
|
||||||
debounce = 0.5;
|
debounce = 0.5;
|
||||||
|
filtered_attributes = [
|
||||||
|
"battery_low"
|
||||||
|
"eurotronic_host_flags"
|
||||||
|
"eurotronic_system_mode"
|
||||||
|
"occupied_heating_setpoint"
|
||||||
|
"pi_heating_demand"
|
||||||
|
"unoccupied_heating_setpoint"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}) allDevices;
|
}) allDevices;
|
||||||
|
|
||||||
|
@ -47,6 +55,15 @@ in {
|
||||||
unit_of_measurement = "lqi";
|
unit_of_measurement = "lqi";
|
||||||
value_template = "{{ value_json.linkquality }}";
|
value_template = "{{ value_json.linkquality }}";
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
platform = "mqtt";
|
||||||
|
name = "temperature_${name}";
|
||||||
|
state_topic = "zigbee2mqtt/${name}";
|
||||||
|
availability_topic = "zigbee2mqtt/bridge/state";
|
||||||
|
unit_of_measurement = "°C";
|
||||||
|
device_class = "temperature";
|
||||||
|
value_template = "{{ value_json.local_temperature }}";
|
||||||
|
}
|
||||||
]) allDevices);
|
]) allDevices);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,83 +25,18 @@ in {
|
||||||
|
|
||||||
services.homeAssistantConfig = {
|
services.homeAssistantConfig = {
|
||||||
|
|
||||||
#light = lib.flatten (lib.mapAttrsToList (name:
|
light = lib.mapAttrsToList (name:
|
||||||
# { ... }: [
|
{ ... }: {
|
||||||
# {
|
platform = "mqtt";
|
||||||
# name = "rgb_${name}";
|
name = name;
|
||||||
# platform = "mqtt";
|
state_topic = "zigbee2mqtt/${name}";
|
||||||
# state_topic = "zigbee2mqtt/${name}";
|
availability_topic = "zigbee2mqtt/bridge/state";
|
||||||
# availability_topic = "zigbee2mqtt/bridge/state";
|
command_topic = "zigbee2mqtt/${name}/set";
|
||||||
# brightness = true;
|
value_template = "{{ value_json.click }}";
|
||||||
# color_temp = true;
|
brightness = true;
|
||||||
# xy = true;
|
color_temp = true;
|
||||||
# schema = "json";
|
schema = "json";
|
||||||
# command_topic = "zigbee2mqtt/${name}/rgb/set";
|
}) allDevices;
|
||||||
# brightness_scale = 254;
|
|
||||||
# state_topic_postfix = "rgb";
|
|
||||||
# }
|
|
||||||
# {
|
|
||||||
# name = "white_${name}";
|
|
||||||
# platform = "mqtt";
|
|
||||||
# state_topic = "zigbee2mqtt/${name}";
|
|
||||||
# availability_topic = "zigbee2mqtt/bridge/state";
|
|
||||||
# brightness = true;
|
|
||||||
# schema = "json";
|
|
||||||
# command_topic = "zigbee2mqtt/${name}/white/set";
|
|
||||||
# brightness_scale = 254;
|
|
||||||
# state_topic_postfix = "white";
|
|
||||||
# }
|
|
||||||
# ]) allDevices);
|
|
||||||
|
|
||||||
#sensor = with lib;
|
|
||||||
# mapAttrsToList (name:
|
|
||||||
# { ... }: {
|
|
||||||
# name = "link_${name}";
|
|
||||||
# platform = "mqtt";
|
|
||||||
# state_topic = "zigbee2mqtt/${name}";
|
|
||||||
# availability_topic = "zigbee2mqtt/bridge/state";
|
|
||||||
# icon = "mdi:signal";
|
|
||||||
# unit_of_measurement = "lqi";
|
|
||||||
# value_template = "{{ value_json.linkquality}}";
|
|
||||||
# }) allDevices;
|
|
||||||
|
|
||||||
# binary_sensor = lib.mapAttrsToList (name:
|
|
||||||
# { ... }: {
|
|
||||||
# name = "update_${name}";
|
|
||||||
# platform = "mqtt";
|
|
||||||
# state_topic = "zigbee2mqtt/${name}";
|
|
||||||
# availability_topic = "zigbee2mqtt/bridge/state";
|
|
||||||
# payload_on = true;
|
|
||||||
# payload_off = false;
|
|
||||||
# value_template = "{{ value_json.update_available }}";
|
|
||||||
# }) allDevices;
|
|
||||||
|
|
||||||
# # create groups
|
|
||||||
# # -------------
|
|
||||||
# group = let
|
|
||||||
|
|
||||||
# # to have nice panels for every device
|
|
||||||
# lightGroups = lib.mapAttrs (name:
|
|
||||||
# { ... }: {
|
|
||||||
# entities = [
|
|
||||||
# "light.${name}"
|
|
||||||
# "sensor.link_${name}"
|
|
||||||
# "binary_sensor.update_${name}"
|
|
||||||
# ];
|
|
||||||
# }) allDevices;
|
|
||||||
|
|
||||||
# # sort lights into given groups.
|
|
||||||
# sortedInGroups = let
|
|
||||||
# groupEntries = lib.zipAttrs (lib.flatten (lib.mapAttrsToList (name:
|
|
||||||
# { groups ? [ ], ... }:
|
|
||||||
# map (groupName: { "${groupName}" = "light.${name}"; }) groups)
|
|
||||||
# allDevices));
|
|
||||||
# in lib.mapAttrs (name: entities: { inherit entities; }) groupEntries;
|
|
||||||
|
|
||||||
# in sortedInGroups // lightGroups // {
|
|
||||||
# all_lights.entities =
|
|
||||||
# lib.mapAttrsToList (name: { ... }: "light.${name}") allDevices;
|
|
||||||
# };
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,38 +4,14 @@ let
|
||||||
# https://www.zigbee2mqtt.io/devices/RTCGQ01LM.html
|
# https://www.zigbee2mqtt.io/devices/RTCGQ01LM.html
|
||||||
allDevices = {
|
allDevices = {
|
||||||
|
|
||||||
"motion_sensor_1" = {
|
"motion_sensor_1" = { id = "0x00158d0002fbd451"; };
|
||||||
id = "0x00158d0002fbd451";
|
"motion_sensor_2" = { id = "0x00158d0002f9a6b8"; };
|
||||||
groups = [ "kitchen_room" "kitchen_room_present" ];
|
"motion_sensor_3" = { id = "0x00158d0002f04522"; };
|
||||||
};
|
"motion_sensor_4" = { id = "0x00158d0002f9a558"; };
|
||||||
"motion_sensor_2" = {
|
"motion_sensor_5" = { id = "0x00158d0002f9a56f"; };
|
||||||
id = "0x00158d0002f9a6b8";
|
"motion_sensor_6" = { id = "0x00158d0002f9a5cb"; };
|
||||||
groups = [ "bed_room" "bed_room_present" ];
|
"motion_sensor_7" = { id = "0x00158d0002f9a6aa"; };
|
||||||
};
|
"motion_sensor_8" = { id = "0x00158d0002f04637"; };
|
||||||
"motion_sensor_3" = {
|
|
||||||
id = "0x00158d0002f04522";
|
|
||||||
groups = [ "living_room" "living_room_present" ];
|
|
||||||
};
|
|
||||||
"motion_sensor_4" = {
|
|
||||||
id = "0x00158d0002f9a558";
|
|
||||||
groups = [ "living_room" "living_room_present" ];
|
|
||||||
};
|
|
||||||
"motion_sensor_5" = {
|
|
||||||
id = "0x00158d0002f9a56f";
|
|
||||||
groups = [ "bath_room" "bath_room_present" ];
|
|
||||||
};
|
|
||||||
"motion_sensor_6" = {
|
|
||||||
id = "0x00158d0002f9a5cb";
|
|
||||||
groups = [ ];
|
|
||||||
};
|
|
||||||
"motion_sensor_7" = {
|
|
||||||
id = "0x00158d0002f9a6aa";
|
|
||||||
groups = [ "bed_room" "bed_room_present" ];
|
|
||||||
};
|
|
||||||
"motion_sensor_8" = {
|
|
||||||
id = "0x00158d0002f04637";
|
|
||||||
groups = [ "bath_room" "bath_room_present" ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
@ -52,6 +28,21 @@ in {
|
||||||
}) allDevices;
|
}) allDevices;
|
||||||
|
|
||||||
services.homeAssistantConfig = {
|
services.homeAssistantConfig = {
|
||||||
|
|
||||||
|
# define meta information sensors
|
||||||
|
binary_sensor = lib.flatten (lib.mapAttrsToList (name:
|
||||||
|
{ ... }: [{
|
||||||
|
name = "${name}";
|
||||||
|
platform = "mqtt";
|
||||||
|
state_topic = "zigbee2mqtt/${name}";
|
||||||
|
availability_topic = "zigbee2mqtt/bridge/state";
|
||||||
|
value_template = "{{ value_json.occupancy }}";
|
||||||
|
#icon = "mdi:battery-10";
|
||||||
|
payload_on = true;
|
||||||
|
payload_off = false;
|
||||||
|
device_class = "motion";
|
||||||
|
}]) allDevices);
|
||||||
|
|
||||||
# define meta information sensors
|
# define meta information sensors
|
||||||
sensor = lib.flatten (lib.mapAttrsToList (name:
|
sensor = lib.flatten (lib.mapAttrsToList (name:
|
||||||
{ ... }: [
|
{ ... }: [
|
||||||
|
|
|
@ -5,100 +5,14 @@ let
|
||||||
allDevices = {
|
allDevices = {
|
||||||
"repeater1" = { id = "0x680ae2fffe6e7dc1"; };
|
"repeater1" = { id = "0x680ae2fffe6e7dc1"; };
|
||||||
"repeater2" = { id = "0x680ae2fffe8e240d"; };
|
"repeater2" = { id = "0x680ae2fffe8e240d"; };
|
||||||
|
"repeater3" = { id = "0x680ae2fffe404f60"; };
|
||||||
|
"repeater4" = { id = "0x680ae2fffe8e2e71"; };
|
||||||
};
|
};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
|
||||||
services.zigbee2mqtt.devices = lib.mapAttrs' (name:
|
services.zigbee2mqtt.devices = lib.mapAttrs' (name:
|
||||||
{ id, ... }: {
|
{ id, ... }: {
|
||||||
name = id;
|
name = id;
|
||||||
value = {
|
value = { friendly_name = name; };
|
||||||
retain = false;
|
|
||||||
friendly_name = name;
|
|
||||||
transition = 1;
|
|
||||||
};
|
|
||||||
}) allDevices;
|
}) allDevices;
|
||||||
|
|
||||||
services.homeAssistantConfig = {
|
|
||||||
|
|
||||||
#light = lib.flatten (lib.mapAttrsToList (name:
|
|
||||||
# { ... }: [
|
|
||||||
# {
|
|
||||||
# name = "rgb_${name}";
|
|
||||||
# platform = "mqtt";
|
|
||||||
# state_topic = "zigbee2mqtt/${name}";
|
|
||||||
# availability_topic = "zigbee2mqtt/bridge/state";
|
|
||||||
# brightness = true;
|
|
||||||
# color_temp = true;
|
|
||||||
# xy = true;
|
|
||||||
# schema = "json";
|
|
||||||
# command_topic = "zigbee2mqtt/${name}/rgb/set";
|
|
||||||
# brightness_scale = 254;
|
|
||||||
# state_topic_postfix = "rgb";
|
|
||||||
# }
|
|
||||||
# {
|
|
||||||
# name = "white_${name}";
|
|
||||||
# platform = "mqtt";
|
|
||||||
# state_topic = "zigbee2mqtt/${name}";
|
|
||||||
# availability_topic = "zigbee2mqtt/bridge/state";
|
|
||||||
# brightness = true;
|
|
||||||
# schema = "json";
|
|
||||||
# command_topic = "zigbee2mqtt/${name}/white/set";
|
|
||||||
# brightness_scale = 254;
|
|
||||||
# state_topic_postfix = "white";
|
|
||||||
# }
|
|
||||||
# ]) allDevices);
|
|
||||||
|
|
||||||
#sensor = with lib;
|
|
||||||
# mapAttrsToList (name:
|
|
||||||
# { ... }: {
|
|
||||||
# name = "link_${name}";
|
|
||||||
# platform = "mqtt";
|
|
||||||
# state_topic = "zigbee2mqtt/${name}";
|
|
||||||
# availability_topic = "zigbee2mqtt/bridge/state";
|
|
||||||
# icon = "mdi:signal";
|
|
||||||
# unit_of_measurement = "lqi";
|
|
||||||
# value_template = "{{ value_json.linkquality}}";
|
|
||||||
# }) allDevices;
|
|
||||||
|
|
||||||
# binary_sensor = lib.mapAttrsToList (name:
|
|
||||||
# { ... }: {
|
|
||||||
# name = "update_${name}";
|
|
||||||
# platform = "mqtt";
|
|
||||||
# state_topic = "zigbee2mqtt/${name}";
|
|
||||||
# availability_topic = "zigbee2mqtt/bridge/state";
|
|
||||||
# payload_on = true;
|
|
||||||
# payload_off = false;
|
|
||||||
# value_template = "{{ value_json.update_available }}";
|
|
||||||
# }) allDevices;
|
|
||||||
|
|
||||||
# # create groups
|
|
||||||
# # -------------
|
|
||||||
# group = let
|
|
||||||
|
|
||||||
# # to have nice panels for every device
|
|
||||||
# lightGroups = lib.mapAttrs (name:
|
|
||||||
# { ... }: {
|
|
||||||
# entities = [
|
|
||||||
# "light.${name}"
|
|
||||||
# "sensor.link_${name}"
|
|
||||||
# "binary_sensor.update_${name}"
|
|
||||||
# ];
|
|
||||||
# }) allDevices;
|
|
||||||
|
|
||||||
# # sort lights into given groups.
|
|
||||||
# sortedInGroups = let
|
|
||||||
# groupEntries = lib.zipAttrs (lib.flatten (lib.mapAttrsToList (name:
|
|
||||||
# { groups ? [ ], ... }:
|
|
||||||
# map (groupName: { "${groupName}" = "light.${name}"; }) groups)
|
|
||||||
# allDevices));
|
|
||||||
# in lib.mapAttrs (name: entities: { inherit entities; }) groupEntries;
|
|
||||||
|
|
||||||
# in sortedInGroups // lightGroups // {
|
|
||||||
# all_lights.entities =
|
|
||||||
# lib.mapAttrsToList (name: { ... }: "light.${name}") allDevices;
|
|
||||||
# };
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue