From 2b47c82f8adcf27f324faa0a4f4fdbc41feb2392 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Wed, 10 Jun 2020 20:35:34 +0300 Subject: [PATCH] Add bedside switch --- .../advanced_dashboard/10_system.yaml | 8 +-- config/packages/devices/bedroom/bed_led.yaml | 20 ++++++++ config/packages/modules/climate/windows.yaml | 50 +++++++++---------- zigbee2mqtt/configuration.yaml | 2 + 4 files changed, 52 insertions(+), 28 deletions(-) create mode 100644 config/packages/devices/bedroom/bed_led.yaml diff --git a/config/lovelace/advanced_dashboard/10_system.yaml b/config/lovelace/advanced_dashboard/10_system.yaml index 2014698..2298d7c 100644 --- a/config/lovelace/advanced_dashboard/10_system.yaml +++ b/config/lovelace/advanced_dashboard/10_system.yaml @@ -44,9 +44,7 @@ cards: - type: custom:battery-entity entity: sensor.front_door_battery - type: custom:battery-entity - entity: sensor.desk_switch_battery - # - type: custom:battery-entity - # entity: sensor.living_room_right_window_power + entity: sensor.living_room_right_window_battery - type: divider - type: custom:battery-entity entity: sensor.bedroom_door_battery @@ -78,6 +76,8 @@ cards: # - type: custom:battery-entity # entity: sensor.master_bedroom_bedside_switch_power # - type: custom:battery-entity + # entity: sensor.master_bedroom_switch_power + # - type: custom:battery-entity # entity: sensor.bathroom_switch_power # - type: custom:battery-entity # entity: sensor.cube_power @@ -88,6 +88,8 @@ cards: entities: - sensor.front_door_lqi - sensor.desk_switch_lqi + - sensor.bed_led_lqi + - sensor.living_room_right_window_lqi - type: divider - sensor.bedroom_door_lqi - sensor.bedroom_left_window_lqi diff --git a/config/packages/devices/bedroom/bed_led.yaml b/config/packages/devices/bedroom/bed_led.yaml new file mode 100644 index 0000000..ff9a515 --- /dev/null +++ b/config/packages/devices/bedroom/bed_led.yaml @@ -0,0 +1,20 @@ +light: + - platform: "mqtt" + name: "Bed LED" + state_topic: "zigbee2mqtt/bed_led" + availability_topic: "zigbee2mqtt/bridge/state" + brightness: true + color_temp: true + xy: true + schema: "json" + command_topic: "zigbee2mqtt/bed_led/set" + brightness_scale: 254 + +sensor: + - platform: "mqtt" + name: "Bed LED LQI" + state_topic: "zigbee2mqtt/bed_led" + availability_topic: "zigbee2mqtt/bridge/state" + icon: "mdi:signal" + unit_of_measurement: "lqi" + value_template: "{{ value_json.linkquality }}" diff --git a/config/packages/modules/climate/windows.yaml b/config/packages/modules/climate/windows.yaml index bfbc3de..c9fcbbd 100644 --- a/config/packages/modules/climate/windows.yaml +++ b/config/packages/modules/climate/windows.yaml @@ -8,6 +8,15 @@ group: - binary_sensor.kitchen_window binary_sensor: + - platform: mqtt + name: "Living room right window" + state_topic: "zigbee2mqtt/living_room_right_window" + availability_topic: "zigbee2mqtt/bridge/state" + payload_on: false + payload_off: true + value_template: "{{ value_json.contact }}" + device_class: "window" + - platform: mqtt name: "Bedroom left window" state_topic: "zigbee2mqtt/bedroom_left_window" @@ -35,20 +44,23 @@ binary_sensor: value_template: "{{ value_json.contact }}" device_class: "window" - - - platform: template - sensors: - living_room_right_window: - friendly_name: Living room window - device_class: window - value_template: "{{ is_state('binary_sensor.living_room_right_window_on_off', 'on') }}" - entity_id: binary_sensor.living_room_right_window_on_off - icon_template: > - {% if is_state('binary_sensor.living_room_right_window_on_off', 'on') %} mdi:window-open-variant - {% else %} mdi:window-closed-variant - {% endif %} - sensor: + - platform: mqtt + name: "Living room right window battery" + state_topic: "zigbee2mqtt/living_room_right_window" + availability_topic: "zigbee2mqtt/bridge/state" + unit_of_measurement: "%" + device_class: "battery" + value_template: "{{ value_json.battery }}" + + - platform: mqtt + name: "Living room right window LQI" + state_topic: "zigbee2mqtt/living_room_right_window" + availability_topic: "zigbee2mqtt/bridge/state" + icon: "mdi:signal" + unit_of_measurement: "lqi" + value_template: "{{ value_json.linkquality }}" + - platform: mqtt name: "Bedroom left window battery" state_topic: "zigbee2mqtt/bedroom_left_window" @@ -109,15 +121,3 @@ sensor: value_template: >- {% set entityStates = states | selectattr('entity_id', 'in', state_attr('group.all_windows', 'entity_id')) %} {{ entityStates | selectattr('state', 'eq', 'on') | list | count | int }} - -# -# ─── CUSTOMIZATION ────────────────────────────────────────────────────────────── -# - -homeassistant: - customize: - sensor.living_room_right_window_power: - friendly_name: Living room window battery - - sensor.kitchen_window_power: - friendly_name: Kitchen window battery diff --git a/zigbee2mqtt/configuration.yaml b/zigbee2mqtt/configuration.yaml index 50c4e3e..626eb40 100644 --- a/zigbee2mqtt/configuration.yaml +++ b/zigbee2mqtt/configuration.yaml @@ -64,3 +64,5 @@ devices: retain: true '0x00124b001f6fc6a2': friendly_name: bed_led + '0x00158d00040249c8': + friendly_name: bedside_switch