I have 6 smart Plugs with cse7766 power measurement chip. As they are all the same, I’ve created a Package with a sensor definition.
For individual Plugs, that use the created hardware package yaml, I’d like to add logic that only applies to a specific plug, such as on_value_range
to the power sensor.
Can I simply add that code in the smart plug’s yaml by recreating the sensor:↵ platform:cse7766↵ power
structure and add in an on_value_range
? Could I instead somehow work with the sensor ID?
My Config Files
WaschmaschieneSmartPlug.yaml
substitutions:
name: "waschmaschine-athom-plug"
friendly_name: "Waschmaschine"
relay_restore_mode: RESTORE_DEFAULT_ON
packages:
connection: !include common/connection.yaml
plug_base: !include common/athom-smart-plug-hardware.yaml
esphome:
name: ${name}
name_add_mac_suffix: false
comment: Dritter Smartplug
wifi:
power_save_mode: HIGH
athom-smart-plug-hardware.yaml
esp8266:
board: esp8285
restore_from_flash: true
preferences:
flash_write_interval: 180sec
logger:
baud_rate: 0 #disable URAT logging
uart:
rx_pin: RX
baud_rate: 4800
switch:
- platform: gpio
#name: "${friendly_name}"
pin: GPIO12
id: relay
restore_mode: ${relay_restore_mode}
sensor:
- platform: cse7766
update_interval: 10s
power:
name: "${friendly_name} Power"
id: power_sensor
filters:
- lambda: if (x < 0.75) return 0.0; else return x; #For the chip will report less than 3w power when no load is connected
energy:
name: "${friendly_name} Energy"
unit_of_measurement: kWh
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
- platform: total_daily_energy
name: "${friendly_name} Total Daily Energy"
restore: true
power_id: power_sensor
unit_of_measurement: kWh
accuracy_decimals: 3
filters:
- multiply: 0.001
time:
- platform: sntp
id: my_time