Hello,
I want following data in home assistant and don’t know how to configure. Can any body please guide me as I am new to home assistant. I am using Sonoff POW R2 devices.
-
Cost of consumption like today consumption is showing but the cost amount is not. I want to calculate cost as per used kwh.
-
Consumption of last x number of days can be displayed but I am not able to get current month consumption. I have added last week consumption for per day using the code I found, which is great, but I want current month consumption.
-
cost of kwh consumed in current month.
-
Average consumption and cost of
- Current month
- X number of days.
I have already tried this using SonoffLAN & Utility meter. I am confused that how to use it.
I have tried following code but getting 0.
utility_meter:
daily_energy:
source: switch.sonoff_xxxxxx
cycle: daily
monthly_energy:
source: switch.sonoff_xxxxxx
cycle: monthly
my following configuring giving me values of current usage in watts and today etc used in kwh.
sonoff:
username: [email protected]
password: xxxxxx
force_update: [temperature, power]
scan_interval: '00:00:10' # (optional) default 5 minutes
sensors: [temperature, humidity, power, current, voltage]
sensor:
platform: template
sensors:
today_consumption:
friendly_name: Today consumpion
unit_of_measurement: kWh
value_template: "{{ state_attr('switch.sonoff_xxxxxx', 'consumption').0 }}"
yesterday_consumption:
friendly_name: Yesterday consumption
unit_of_measurement: kWh
value_template: "{{ state_attr('switch.sonoff_xxxxxx', 'consumption').1 }}"
ten_days_consumption:
friendly_name: 10 days consumpion
unit_of_measurement: kWh
value_template: "{% set p=state_attr('switch.sonoff_xxxxxx', 'consumption') %}{{ p[:10]|sum if p }}"
thirty_days_consumption:
friendly_name: 30 days consumpion
unit_of_measurement: kWh
value_template: "{% set p=state_attr('switch.sonoff_xxxxxx', 'consumption') %}{{ p[:30]|sum if p }}"
Now I don’t know how to calculate current month kwh usage and average usage of current month in kwh.
Plus, I want to add electricity cost to it so I can get daily, monthly costs and average per day costs etc.