| « Hackintosh VM | IR Blaster » |
Sonoff S31 Smart Plug with Energy Monitoring
I have been after an energy monitoring solution like the S31 provides for years. The smart switch is actually not a need as my use cases (TV's, Lights) generally have IR commands to toggle power. There are a couple of setup options that make this work best for me in my home automation cases:
First - load Tasmota on the S31
Enable auto discovery: SetOption19 1
Set the Power Delta value to force a MQTT update on power change: PowerDelta 10
In Home Assistant, create a template in configuration.yaml
- platform: template
switches:
living_room_tv:
unique_id: "12833912801831"
friendly_name: "Living Room TV"
value_template: "{{ states('sensor.s3102_energy_power')|float > 1 }}"
turn_on:
- service: rest_command.ircontroller02
data:
ir_data:
- data: E0E040BF
type: Samsung
length: '32'
turn_off:
- service: rest_command.ircontroller02
data:
ir_data:
- data: E0E040BF
type: Samsung
length: '32'
And add any automations in automations.yaml
- id: '8349207385890'
alias: Turn Off Living Room TV When Idle
trigger:
platform: numeric_state
entity_id: sensor.s3102_energy_power
below: 130
for:
minutes: 10
condition:
- condition: state
entity_id: switch.living_room_tv
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.living_room_tv
Here are related links: