Skip to content

Commit

Permalink
Merge pull request #68 from Roving-Ronin/Roving-Ronin-Plug-v1-to-v2an…
Browse files Browse the repository at this point in the history
…dv3-Baseline

Update Smart Plug v1 to same code as v2 and v3
  • Loading branch information
tarontop authored Aug 28, 2024
2 parents 46081a9 + 53230ad commit f17e1b5
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 15 deletions.
75 changes: 67 additions & 8 deletions athom-smart-plug-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,33 @@ substitutions:
device_description: "athom smart plug v2"
project_name: "Athom Technology.Smart Plug V2"
project_version: "2.0.4"
sensor_update_interval: "10s"
relay_restore_mode: RESTORE_DEFAULT_OFF
sensor_update_interval: 10s
# Current Limit in Amps. AU Plug = 10. IL, BR, EU, UK, US Plug = 16.
current_limit : "16"
# Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
dns_domain: ""
# Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
timezone: ""
# Set the duration between the sntp service polling ntp.org servers for an update
sntp_update_interval: "6h"
# Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
sntp_server_1: "0.pool.ntp.org"
sntp_server_2: "1.pool.ntp.org"
sntp_server_3: "2.pool.ntp.org"
# Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
wifi_fast_connect: "false"

wifi_fast_connect: "false"
# Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
log_level: "INFO"
# Hide the ENERGY sensor that shows kWh consumed, but with no time period associated with it. Resets when device restarted and reflashed.
hide_energy_sensor: "true"



esphome:
name: "${name}"
friendly_name: "${friendly_name}"
comment: "${device_description}"
area: "${room}"
name_add_mac_suffix: true
min_version: 2024.6.0
Expand All @@ -40,6 +53,7 @@ ota:
- platform: esphome

logger:
level: ${log_level}
baud_rate: 0

mdns:
Expand All @@ -49,15 +63,23 @@ web_server:
port: 80

wifi:
ap: {} # This spawns an AP with the device name and mac address with no password.
# This spawns an AP with the device name and mac address with no password.
ap: {}
# Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
fast_connect: "${wifi_fast_connect}"
# Define dns domain / suffix to add to hostname
domain: "${dns_domain}"

captive_portal:

dashboard_import:
package_import_url: github://athom-tech/athom-configs/athom-smart-plug-v2.yaml

# Dentra Components - Adds 'Platform - Energy Statistics'
# https://github.com/dentra/esphome-components/tree/master/components/energy_statistics
# external_components:
# - source: github://dentra/esphome-components

uart:
rx_pin: RX
baud_rate: 4800
Expand Down Expand Up @@ -154,11 +176,13 @@ sensor:
id(total_energy) += current_energy_value - previous_energy_value;
previous_energy_value = current_energy_value;
id(total_energy_sensor).update();
# internal: ${hide_energy_sensor}

apparent_power:
name: "Apparent Power"
filters:
- throttle_average: ${sensor_update_interval}

power_factor:
name: "Power Factor"
filters:
Expand All @@ -174,17 +198,47 @@ sensor:
accuracy_decimals: 3
lambda: |-
return id(total_energy);
update_interval: never
update_interval: ${sensor_update_interval}

- platform: total_daily_energy
name: "Total Daily Energy"
name: "Total Energy Since Boot"
restore: true
power_id: power_sensor
unit_of_measurement: kWh
icon: mdi:hours-24
accuracy_decimals: 3
filters:
- multiply: 0.001

# # Dentra Components - Define the id of the sensor providing 'Total Energy' used
# - platform: "energy_statistics"
# total: total_energy_sensor

# # Dentra Components - Adds Energy Today. Persistents if restarted, unlike 'total_daily_energy'
# energy_today:
# name: "Energy Today"
# id: total_energy_today
# accuracy_decimals: 3
# icon: mdi:hours-24

# # Dentra Components - Adds Energy Yesterday
# energy_yesterday:
# name: "Total Energy Yesterday"
# id: total_energy_yesterday
# accuracy_decimals: 3

# # Dentra Components - Adds Energy Week
# energy_week:
# name: "Total Energy Week"
# id: total_energy_week
# accuracy_decimals: 3

# # Dentra Components - Adds Energy Month
# energy_month:
# name: "Total Energy Month"
# id: total_energy_month
# accuracy_decimals: 3

button:
- platform: restart
name: "Restart"
Expand Down Expand Up @@ -266,8 +320,13 @@ time:
id: sntp_time
# Define the timezone of the device
timezone: "${timezone}"
# Change sync interval from default 5min to 6 hours
update_interval: 360min
# Change sync interval from default 5min to 6 hours (or as set in substitutions)
update_interval: ${sntp_update_interval}
# Set specific sntp servers to use
servers:
- "${sntp_server_1}"
- "${sntp_server_2}"
- "${sntp_server_3}"
# Publish the time the device was last restarted
on_time_sync:
then:
Expand Down
Loading

0 comments on commit f17e1b5

Please sign in to comment.