From b1f1cd47066742232879f0060637d8073264f680 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Mon, 20 Apr 2020 00:16:34 +0300 Subject: [PATCH] Add outlet_1 power monitoring in living room --- .../home_dashboard/01_living_room.yaml | 12 ++++ config/packages/modules/lighting/mqtt.yaml | 18 +++--- config/packages/modules/power.yaml | 63 +++++++++++++++++++ 3 files changed, 84 insertions(+), 9 deletions(-) create mode 100644 config/packages/modules/power.yaml diff --git a/config/lovelace/home_dashboard/01_living_room.yaml b/config/lovelace/home_dashboard/01_living_room.yaml index b370a35..a36fe6b 100644 --- a/config/lovelace/home_dashboard/01_living_room.yaml +++ b/config/lovelace/home_dashboard/01_living_room.yaml @@ -98,6 +98,18 @@ cards: entities: - binary_sensor.living_room_right_window_on_off_wrapper - sensor.living_room_right_window_power + - type: entities + title: Power + entities: + - switch.outlet_1_switch + - sensor.outlet_1_power + - sensor.outlet_1_voltage + - sensor.outlet_1_current + - sensor.outlet_1_energy_today + - sensor.outlet_1_energy_yesterday + - sensor.outlet_1_energy_total + - sensor.outlet_1_energy_total_start_time + - sensor.outlet_1_wifi - type: vertical-stack cards: diff --git a/config/packages/modules/lighting/mqtt.yaml b/config/packages/modules/lighting/mqtt.yaml index 38c374a..aec5187 100644 --- a/config/packages/modules/lighting/mqtt.yaml +++ b/config/packages/modules/lighting/mqtt.yaml @@ -227,7 +227,7 @@ sensor: payload_not_available: "Offline" state_topic: "tele/pc_light/STATE" unit_of_measurement: "%" - value_template: "{{ value_json['Wifi'].RSSI }}" + value_template: "{{ value_json.Wifi.RSSI }}" - platform: mqtt name: "light_le_1_wifi" @@ -237,7 +237,7 @@ sensor: payload_not_available: "Offline" state_topic: "tele/light_le_1/STATE" unit_of_measurement: "%" - value_template: "{{ value_json['Wifi'].RSSI }}" + value_template: "{{ value_json.Wifi.RSSI }}" - platform: mqtt name: "light_le_2_wifi" @@ -247,7 +247,7 @@ sensor: payload_not_available: "Offline" state_topic: "tele/light_le_2/STATE" unit_of_measurement: "%" - value_template: "{{ value_json['Wifi'].RSSI }}" + value_template: "{{ value_json.Wifi.RSSI }}" - platform: mqtt name: "light_le_3_wifi" @@ -257,7 +257,7 @@ sensor: payload_not_available: "Offline" state_topic: "tele/light_le_3/STATE" unit_of_measurement: "%" - value_template: "{{ value_json['Wifi'].RSSI }}" + value_template: "{{ value_json.Wifi.RSSI }}" - platform: mqtt name: "light_le_4_wifi" @@ -267,7 +267,7 @@ sensor: payload_not_available: "Offline" state_topic: "tele/light_le_4/STATE" unit_of_measurement: "%" - value_template: "{{ value_json['Wifi'].RSSI }}" + value_template: "{{ value_json.Wifi.RSSI }}" - platform: mqtt name: "light_lohas_1_wifi" @@ -277,7 +277,7 @@ sensor: payload_not_available: "Offline" state_topic: "tele/light_lohas_1/STATE" unit_of_measurement: "%" - value_template: "{{ value_json['Wifi'].RSSI }}" + value_template: "{{ value_json.Wifi.RSSI }}" - platform: mqtt name: "light_lohas_2_wifi" @@ -287,7 +287,7 @@ sensor: payload_not_available: "Offline" state_topic: "tele/light_lohas_2/STATE" unit_of_measurement: "%" - value_template: "{{ value_json['Wifi'].RSSI }}" + value_template: "{{ value_json.Wifi.RSSI }}" - platform: mqtt name: "light_lohas_3_wifi" @@ -297,7 +297,7 @@ sensor: payload_not_available: "Offline" state_topic: "tele/light_lohas_3/STATE" unit_of_measurement: "%" - value_template: "{{ value_json['Wifi'].RSSI }}" + value_template: "{{ value_json.Wifi.RSSI }}" - platform: mqtt name: "light_lohas_4_wifi" @@ -307,7 +307,7 @@ sensor: payload_not_available: "Offline" state_topic: "tele/light_lohas_4/STATE" unit_of_measurement: "%" - value_template: "{{ value_json['Wifi'].RSSI }}" + value_template: "{{ value_json.Wifi.RSSI }}" switch: - platform: mqtt diff --git a/config/packages/modules/power.yaml b/config/packages/modules/power.yaml new file mode 100644 index 0000000..d8878bb --- /dev/null +++ b/config/packages/modules/power.yaml @@ -0,0 +1,63 @@ +switch: + - platform: mqtt + name: "Outlet 1 switch" + state_topic: "stat/outlet_1/RESULT" + value_template: "{{ value_json.POWER }}" + command_topic: "cmnd/outlet_1/POWER" + payload_on: "ON" + payload_off: "OFF" + availability_topic: "tele/outlet_1/LWT" + payload_available: "Online" + payload_not_available: "Offline" + qos: 1 + +sensor: + - platform: mqtt + name: "Outlet 1 Energy today" + state_topic: "tele/outlet_1/SENSOR" + value_template: '{{ value_json.ENERGY.Today }}' + device_class: power + unit_of_measurement: "kWh" + - platform: mqtt + name: "Outlet 1 Energy yesterday" + state_topic: "tele/outlet_1/SENSOR" + value_template: '{{ value_json.ENERGY.Yesterday }}' + device_class: power + unit_of_measurement: "kWh" + - platform: mqtt + name: "Outlet 1 Energy total" + state_topic: "tele/outlet_1/SENSOR" + value_template: '{{ value_json.ENERGY.Total }}' + device_class: power + unit_of_measurement: "kWh" + - platform: mqtt + name: "Outlet 1 Energy total start time" + state_topic: "tele/outlet_1/SENSOR" + value_template: '{{ value_json.ENERGY.TotalStartTime }}' + device_class: timestamp + - platform: mqtt + name: "Outlet 1 Power" + state_topic: "tele/outlet_1/SENSOR" + value_template: '{{ value_json.ENERGY.Power }}' + device_class: power + unit_of_measurement: "W" + - platform: mqtt + name: "Outlet 1 Voltage" + state_topic: "tele/outlet_1/SENSOR" + value_template: '{{ value_json.ENERGY.Voltage }}' + unit_of_measurement: "V" + - platform: mqtt + name: "Outlet 1 Current" + state_topic: "tele/outlet_1/SENSOR" + value_template: '{{ value_json.ENERGY.Current }}' + unit_of_measurement: "A" + + - platform: mqtt + name: "Outlet 1 WiFi" + state_topic: "tele/outlet_1/STATE" + unit_of_measurement: "%" + value_template: "{{value_json.Wifi.RSSI }}" + availability_topic: "tele/outlet_1/LWT" + payload_available: "Online" + payload_not_available: "Offline" + device_class: signal_strength