I am trying to improve my HAOS setup, it have been negligenced for ages and I just performed a clean Proxmox HAOS setup.
Context:
So, I have a few of these Athom smart plugs like this plug for my 3D printer.
Also, I pay electricity based on the time of the day like peak hour, off-peak, shoulder, others.
Question:
Is there a way to fetch the values from the Athom plugs and have a logic in place to do for example:
if hour =< 14PM
kWh = $0.38500
if hour > 14PM
kWh = $0.21450
if hour > 20PM
kWh = $0.10000
Logic to calculate the "Athom Smart Plug V2 Energy" in currency value
idk if this is remotely possible but would love some input
Thank you
IMHO you’d be better off just working out your house (overall) costs. If however for some reason you wanted the running cost on a per plug basis, you’d be better off still defining a ‘Electricity - Cost’ sensor and having the plug query that, instead of manually defining the cost within the plug firmware.
template:
- sensor:
# Electricity_Price provides a method to allow selecting the 'Use an entity with current rate' in Energy Dashboard.
#
# This tariff plan is based upon a Time of Use (ToU) plan with different charges at the following times:
#
# Peak : $0.38500 p/kWh. Between 12:00am - 2:00pm.
# Shoulder : $0.21450 p/kWh. Between 2:00pm - 8:00pm.
# Off-Peak : $0.10000 p/kWh. Between 8:00pm - 12:00am.
#
# Note: If you energy provider plan has different times, you must update them below AND also in the Automation (that updates the Selector) at the bottom.
#
- name: "Electricity - Price"
unique_id: electricity_price
unit_of_measurement: "$/kWh"
device_class: monetary
state: "
{%set Peak = 0.38500 %}
{%set Shoulder = 0.21450 %}
{%set OffPeak = 0.10000 %}
{%set H = as_timestamp(now())|timestamp_custom ('%-H')|float(0) %} {##Hour (24-hour clock) as a decimal number. 0, 1, 2, ... 23##}
{##peak##}
{% if (H >= 0) and (H < 14) %} {{Peak}}
{##shoulder##}
{% elif (H >= 14) and (H < 20) %} {{Shoulder}}
{##off peak##}
{% else %} {{OffPeak}}
{% endif %}
"
This should give you a Electricity_Price sensor in HA, that will constantly update based on the time periods to publish ‘the’ current price. You could then query this in ESPHome to make a cost sensor. See: Home Assistant Sensor — ESPHome , something like:
I would suggest raising this as an idea in athom-tech/athom-configs Ideas · Discussions · GitHub and see if there is wider interest in doing this and if Athom would support adding it for everyone? (this would require Athom to publish some example electricity_price yaml sensors to guide people depending upon if they are flat rate, Time of Use (ToU) etc for their energy costs.