From 3f60fcdae558efcec92f874e9c785ec804931867 Mon Sep 17 00:00:00 2001 From: Jan Grewe <jan@faked.org> Date: Wed, 18 May 2022 15:33:57 +0200 Subject: [PATCH] initial commit --- .gitignore | 5 ++ common.yaml | 37 ++++++++++++++ include/text_sensors.yaml | 12 +++++ propbox-light.yaml | 101 ++++++++++++++++++++++++++++++++++++++ propbox.yaml | 44 +++++++++++++++++ secrets.yaml.dist | 4 ++ 6 files changed, 203 insertions(+) create mode 100644 .gitignore create mode 100644 common.yaml create mode 100644 include/text_sensors.yaml create mode 100644 propbox-light.yaml create mode 100644 propbox.yaml create mode 100644 secrets.yaml.dist diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d8b4157 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# Gitignore settings for ESPHome +# This is an example and may include too much for your use-case. +# You can modify this file to suit your needs. +/.esphome/ +/secrets.yaml diff --git a/common.yaml b/common.yaml new file mode 100644 index 0000000..e02a724 --- /dev/null +++ b/common.yaml @@ -0,0 +1,37 @@ +esphome: + name: $devicename + comment: $comment + project: + name: $project_name + version: $project_version + +logger: +# level: INFO + +api: + password: !secret api_password + reboot_timeout: 0s + +ota: + password: !secret ota_password + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + fast_connect: on + ap: + ssid: "$devicename Fallback Hotspot" + password: !secret wifi_password + +captive_portal: + +web_server: + port: 80 + local: true + # include_internal: true + +time: + - platform: sntp + id: sntp_time + +prometheus: diff --git a/include/text_sensors.yaml b/include/text_sensors.yaml new file mode 100644 index 0000000..44ec329 --- /dev/null +++ b/include/text_sensors.yaml @@ -0,0 +1,12 @@ +- platform: wifi_info + ip_address: + name: "IP Address" + ssid: + name: "Wifi SSID" + bssid: + name: "Wifi BSSID" + +- platform: version + name: "ESPHome Version" + hide_timestamp: true + diff --git a/propbox-light.yaml b/propbox-light.yaml new file mode 100644 index 0000000..7a3c80d --- /dev/null +++ b/propbox-light.yaml @@ -0,0 +1,101 @@ +substitutions: + devicename: "propbox-light" + comment: "Propagator Light Control" + project_name: "groovy.propbox-light" + project_version: "1.0" + + current_res: "0.00280" # Higher value gives lower watt readout + voltage_div: "775" # Lower value gives lower voltage readout + +<<: !include common.yaml + +esp8266: + board: esp8285 + +light: + - platform: status_led + id: "led_status" + pin: + number: GPIO13 + inverted: true + +binary_sensor: + # toggle relay on/off + - platform: gpio + id: "button_state" + pin: + number: GPIO00 + mode: INPUT_PULLUP + on_press: + - switch.toggle: "button_switch" + +switch: + - platform: template + name: "Switch" + optimistic: true + id: "button_switch" + lambda: |- + if (id(relay).state) { + return true; + } else { + return false; + } + turn_on_action: + - switch.turn_on: "relay" + - light.turn_on: "led_status" + turn_off_action: + - switch.turn_off: "relay" + - light.turn_off: "led_status" + - platform: gpio + id: relay + pin: GPIO14 + +sensor: + - platform: wifi_signal + name: "Wifi Signal" + update_interval: 60s + + - platform: uptime + name: "Uptime" + update_interval: 60s + + - platform: total_daily_energy + name: "Electric Consumption [kWh]" + power_id: "nous_a1t_watt" + filters: + # Multiplication factor from W to kW is 0.001 + - multiply: 0.001 + unit_of_measurement: kWh + + - platform: adc + pin: VCC + name: "VCC Volt" + + - platform: hlw8012 + sel_pin: + number: GPIO12 + inverted: True + cf_pin: GPIO04 + cf1_pin: GPIO05 + change_mode_every: 4 + current_resistor: ${current_res} + voltage_divider: ${voltage_div} + update_interval: 3s + + current: + name: "Ampere" + unit_of_measurement: A + accuracy_decimals: 3 + + voltage: + name: "Voltage" + unit_of_measurement: V + accuracy_decimals: 1 + + power: + name: "Power" + id: "nous_a1t_watt" + unit_of_measurement: W + +text_sensor: + !include include/text_sensors.yaml diff --git a/propbox.yaml b/propbox.yaml new file mode 100644 index 0000000..aac58c0 --- /dev/null +++ b/propbox.yaml @@ -0,0 +1,44 @@ +substitutions: + devicename: "propbox" + comment: "Propagator Monitor" + project_name: "groovy.propbox" + project_version: "1.0" + + sensor_mac: "A4:C1:38:47:14:50" + +<<: !include common.yaml + +esp32: + board: esp32dev + +esp32_ble_tracker: + +sensor: + - platform: wifi_signal + name: "Wifi Signal" + update_interval: 60s + + - platform: uptime + name: "Uptime" + update_interval: 60s + + - platform: wifi_signal + name: "RSSI" + update_interval: 60s + + - platform: uptime + name: "Uptime" + update_interval: 60s + + - platform: pvvx_mithermometer + mac_address: $sensor_mac + temperature: + name: "Temperature" + humidity: + name: "Humidity" + battery_level: + name: "Battery Level" + battery_voltage: + name: "Battery Voltage" + +text_sensor: !include include/text_sensors.yaml diff --git a/secrets.yaml.dist b/secrets.yaml.dist new file mode 100644 index 0000000..94d6535 --- /dev/null +++ b/secrets.yaml.dist @@ -0,0 +1,4 @@ +wifi_ssid: foo +wifi_password: bar +ota_password: baz +api_password: qux \ No newline at end of file -- GitLab