From 5c7c1a20604735e6aa1f46b656849c0672362e50 Mon Sep 17 00:00:00 2001 From: Chris Nussbaum Date: Tue, 28 Sep 2021 21:26:13 -0500 Subject: [PATCH] Add a bunch of smartplugs for energy monitoring (#28) --- devices/basement-fridge.yaml | 10 +++++ devices/basement-tv.yaml | 10 +++++ devices/family-room-tv.yaml | 10 +++++ devices/kitchen-fridge.yaml | 10 +++++ devices/network_equipment.yaml | 10 +++++ devices/sump_pump.yaml | 10 +++++ devices/washing-machine.yaml | 10 +++++ packages/topgreener_smart_plug.yaml | 69 +++++++++++++++++++++++++++++ scripts/secrets.ps1 | 2 +- 9 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 devices/basement-fridge.yaml create mode 100644 devices/basement-tv.yaml create mode 100644 devices/family-room-tv.yaml create mode 100644 devices/kitchen-fridge.yaml create mode 100644 devices/network_equipment.yaml create mode 100644 devices/sump_pump.yaml create mode 100644 devices/washing-machine.yaml create mode 100644 packages/topgreener_smart_plug.yaml diff --git a/devices/basement-fridge.yaml b/devices/basement-fridge.yaml new file mode 100644 index 0000000..215ef8d --- /dev/null +++ b/devices/basement-fridge.yaml @@ -0,0 +1,10 @@ +substitutions: + device_id: basement-fridge + device_name: Basement Fridge + ip_address: !secret basement-fridge-ip + ota_pwd: !secret basement-fridge-ota-pwd + api_pwd: !secret basement-fridge-api-pwd + ap_wifi_pwd: !secret basement-fridge-ap-pwd + +packages: + feit_dimmer: !include ../packages/topgreener_smart_plug.yaml diff --git a/devices/basement-tv.yaml b/devices/basement-tv.yaml new file mode 100644 index 0000000..c97e842 --- /dev/null +++ b/devices/basement-tv.yaml @@ -0,0 +1,10 @@ +substitutions: + device_id: basement-tv + device_name: Basement TV + ip_address: !secret basement-tv-ip + ota_pwd: !secret basement-tv-ota-pwd + api_pwd: !secret basement-tv-api-pwd + ap_wifi_pwd: !secret basement-tv-ap-pwd + +packages: + feit_dimmer: !include ../packages/topgreener_smart_plug.yaml diff --git a/devices/family-room-tv.yaml b/devices/family-room-tv.yaml new file mode 100644 index 0000000..79a71b5 --- /dev/null +++ b/devices/family-room-tv.yaml @@ -0,0 +1,10 @@ +substitutions: + device_id: family-room-tv + device_name: Family Room TV + ip_address: !secret family-room-tv-ip + ota_pwd: !secret family-room-tv-ota-pwd + api_pwd: !secret family-room-tv-api-pwd + ap_wifi_pwd: !secret family-room-tv-ap-pwd + +packages: + feit_dimmer: !include ../packages/topgreener_smart_plug.yaml diff --git a/devices/kitchen-fridge.yaml b/devices/kitchen-fridge.yaml new file mode 100644 index 0000000..fc33cbd --- /dev/null +++ b/devices/kitchen-fridge.yaml @@ -0,0 +1,10 @@ +substitutions: + device_id: kitchen-fridge + device_name: Kitchen Fridge + ip_address: !secret kitchen-fridge-ip + ota_pwd: !secret kitchen-fridge-ota-pwd + api_pwd: !secret kitchen-fridge-api-pwd + ap_wifi_pwd: !secret kitchen-fridge-ap-pwd + +packages: + feit_dimmer: !include ../packages/topgreener_smart_plug.yaml diff --git a/devices/network_equipment.yaml b/devices/network_equipment.yaml new file mode 100644 index 0000000..b0d1b4d --- /dev/null +++ b/devices/network_equipment.yaml @@ -0,0 +1,10 @@ +substitutions: + device_id: network_equipment + device_name: Network Equipment + ip_address: !secret network-equipment-ip + ota_pwd: !secret network-equipment-ota-pwd + api_pwd: !secret network-equipment-api-pwd + ap_wifi_pwd: !secret network-equipment-ap-pwd + +packages: + feit_dimmer: !include ../packages/topgreener_smart_plug.yaml diff --git a/devices/sump_pump.yaml b/devices/sump_pump.yaml new file mode 100644 index 0000000..6de7cf8 --- /dev/null +++ b/devices/sump_pump.yaml @@ -0,0 +1,10 @@ +substitutions: + device_id: sump_pump + device_name: Sump Pump + ip_address: !secret sump-pump-ip + ota_pwd: !secret sump-pump-ota-pwd + api_pwd: !secret sump-pump-api-pwd + ap_wifi_pwd: !secret sump-pump-ap-pwd + +packages: + feit_dimmer: !include ../packages/topgreener_smart_plug.yaml diff --git a/devices/washing-machine.yaml b/devices/washing-machine.yaml new file mode 100644 index 0000000..7bad4d2 --- /dev/null +++ b/devices/washing-machine.yaml @@ -0,0 +1,10 @@ +substitutions: + device_id: washing-machine + device_name: Washing Machine + ip_address: !secret washing-machine-ip + ota_pwd: !secret washing-machine-ota-pwd + api_pwd: !secret washing-machine-api-pwd + ap_wifi_pwd: !secret washing-machine-ap-wifi-pwd + +packages: + feit_dimmer: !include ../packages/topgreener_smart_plug.yaml diff --git a/packages/topgreener_smart_plug.yaml b/packages/topgreener_smart_plug.yaml new file mode 100644 index 0000000..007352e --- /dev/null +++ b/packages/topgreener_smart_plug.yaml @@ -0,0 +1,69 @@ +# Model TGWF115PQM +substitutions: + platform: ESP8266 + board: esp01_1m + restore_mode: ALWAYS_ON + +external_components: + - source: github://cbpowell/ESPSense + components: [ espsense ] + +packages: + base: !include device_base.yaml + logger: !include logger/logger_no_serial.yaml + +binary_sensor: + - platform: gpio + id: button + pin: + number: GPIO3 + inverted: True + on_press: + then: + - switch.toggle: relay + +espsense: + plugs: + - name: ${device_name} + power_sensor: power + voltage: 120 + +sensor: + - platform: hlw8012 + sel_pin: + number: GPIO12 + inverted: True + cf_pin: GPIO04 + cf1_pin: GPIO5 + current_resistor: "0.0019" + voltage_divider: "2150" + current: + name: ${device_name} Current + unit_of_measurement: A + power: + id: power + name: ${device_name} Power + unit_of_measurement: W + initial_mode: CURRENT + change_mode_every: 4294967295 + update_interval: 2s + - platform: total_daily_energy + name: ${device_name} + power_id: power + method: trapezoid + min_save_interval: 10min + +status_led: + pin: + number: GPIO13 + inverted: False + +switch: + - platform: gpio + name: ${device_name} Power Switch + id: relay + pin: GPIO14 + restore_mode: ${restore_mode} + +time: + - platform: homeassistant diff --git a/scripts/secrets.ps1 b/scripts/secrets.ps1 index 3507d6b..427f742 100644 --- a/scripts/secrets.ps1 +++ b/scripts/secrets.ps1 @@ -59,7 +59,7 @@ if ($Args[0] -eq "add") $secrets["${device}-ota-pwd"] = -join ((48..57) + (65..90) + (97..122) | Get-Random -Count 16 | % {[char]$_}) $secrets["${device}-ap-pwd"] = -join ((48..57) + (65..90) + (97..122) | Get-Random -Count 16 | % {[char]$_}) - Out-File $PSScriptRoot\..\secrets.yaml -InputObject (ConvertTo-YAML $secrets) + Out-File $PSScriptRoot\..\secrets.yaml -InputObject (ConvertTo-YAML $secrets) -Encoding utf8 } if (!$secrets.Contains("${device}-ip"))