Skip to content

Instantly share code, notes, and snippets.

@xbmcnut
Created March 23, 2019 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xbmcnut/4be84e447c28fa7bc03e3488d85bb744 to your computer and use it in GitHub Desktop.
Save xbmcnut/4be84e447c28fa7bc03e3488d85bb744 to your computer and use it in GitHub Desktop.
Power monitoring and costing package using mostly Xiaomi smart Xigbee sockets
sensor:
- platform: template
sensors:
total_power_usage:
value_template: '{{ ((states.sensor.xiaomi_tv_power.state | float) +
(states.sensor.xiaomi_office_power.state | float) +
(states.sensor.xiaomi_server_power.state | float) +
(states.sensor.pool_pump_power.state | float) +
(states.sensor.cupboard_light_power.state | float) +
(states.sensor.stairs_shelly_power.state | float) +
(states.sensor.davids_light_power.state | float) +
(states.sensor.lounge_light_power.state | float) +
(states.sensor.washing_machine_power.state | float) +
(states.sensor.zwave_garage_light_west_power.state | float) +
(states.sensor.family_room_shelly_power.state | float)) | round(2) }}'
friendly_name: 'Total Power Use'
unit_of_measurement: 'W'
lights_power_usage:
value_template: '{{ ((states.sensor.stairs_shelly_power.state | float) +
(states.sensor.cupboard_light_power.state | float) +
(states.sensor.davids_light_power.state | float) +
(states.sensor.lounge_light_power.state | float) +
(states.sensor.zwave_garage_light_west_power.state | float) +
(states.sensor.family_room_shelly_power.state | float)) | round(2) }}'
friendly_name: 'Lights Power Use'
unit_of_measurement: 'W'
monthly_electricty_kw_use:
value_template: '{{ ((states.sensor.monthly_energy.state)) | multiply(0.001) | round(3) }}'
friendly_name: 'Monthly kW Use'
unit_of_measurement: 'kWh'
monthly_house_kw_use:
value_template: '{{ ((states.sensor.house_energy_m.state)) | multiply(0.001) | round(2) }}'
friendly_name: 'House kW Use | Mnth'
unit_of_measurement: 'kWh'
pool_monthly_electricty_cost:
value_template: '{{ ((states.sensor.monthly_energy_pool.state | multiply(0.001) | float * 0.2023)) | round(2) }}'
friendly_name: 'Pool Pump Monthly Cost'
unit_of_measurement: '$'
server_monthly_electricty_cost:
value_template: '{{ ((states.sensor.server_cabinet_m.state | multiply(0.001) | float * 0.2023)) | round(2) }}'
friendly_name: 'Server Monthly Cost'
unit_of_measurement: '$'
ali_office_monthly_electricty_cost:
value_template: '{{ ((states.sensor.ali_office_m.state | multiply(0.001) | float * 0.2023)) | round(2) }}'
friendly_name: 'Ali Office Monthly Cost'
unit_of_measurement: '$'
tv_cabinet_monthly_electricty_cost:
value_template: '{{ ((states.sensor.tv_cabinet_m.state | multiply(0.001) | float * 0.2023)) | round(2) }}'
friendly_name: 'TV Cabinet Monthly Cost'
unit_of_measurement: '$'
fridge_upstairs_monthly_electricty_cost:
value_template: '{{ ((states.sensor.fridge_upstairs_m.state | multiply(0.001) | float * 0.2023)) | round(2) }}'
friendly_name: 'Upstairs Fridge Monthly Cost'
unit_of_measurement: '$'
total_monthly_electricty_cost:
value_template: '{{ ((states.sensor.monthly_energy.state | multiply(0.001) | float * 0.2023)) | round(2) }}'
friendly_name: 'Total Monthly Cost'
unit_of_measurement: '$'
total_house_electricty_cost:
value_template: '{{ ((states.sensor.house_energy_m.state | multiply(0.001) | float * 0.2023)) | round(2) }}'
friendly_name: 'Total Global Monthly Cost'
unit_of_measurement: '$'
- platform: modbus
# scan_interval: 30
registers:
- name: Volts_Reg0
unit_of_measurement: V
register: 0
register_type: input
count: 2
slave: 1
precision: 2
data_type: float
- name: Amps_Reg6
unit_of_measurement: A
register: 6
register_type: input
count: 2
slave: 1
precision: 2
data_type: float
- name: W_Reg12
unit_of_measurement: W
register: 12
register_type: input
count: 2
slave: 1
precision: 2
data_type: float
# reverse_order: true
- name: Hz_Reg70
unit_of_measurement: Hz
register: 70
register_type: input
count: 2
slave: 1
precision: 2
data_type: float
- name: kWh_Reg342
unit_of_measurement: kWh
register: 342
register_type: input
count: 2
slave: 1
precision: 2
data_type: float
modbus:
type: tcp
host: 10.0.1.10
port: 26
utility_meter:
daily_energy:
source: sensor.total_power_usage
cycle: daily
monthly_energy:
source: sensor.total_power_usage
cycle: monthly
house_energy_d:
source: sensor.w_reg12
cycle: daily
house_energy_m:
source: sensor.w_reg12
cycle: monthly
daily_energy_pool:
source: sensor.pool_pump_power
cycle: daily
monthly_energy_pool:
source: sensor.pool_pump_power
cycle: monthly
server_cabinet_d:
source: sensor.xiaomi_server_power
cycle: daily
server_cabinet_m:
source: sensor.xiaomi_server_power
cycle: monthly
ali_office_d:
source: sensor.xiaomi_office_power
cycle: daily
ali_office_m:
source: sensor.xiaomi_office_power
cycle: monthly
tv_cabinet_d:
source: sensor.xiaomi_tv_power
cycle: daily
tv_cabinet_m:
source: sensor.xiaomi_tv_power
cycle: monthly
fridge_upstairs_m:
source: sensor.xiaomi_fridge_upstairs_power
cycle: monthly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment