Někde jsem už dával odkaz, ale hodím to sem:
Kód: Vybrat vše
#...
web_server:
sensor:
- platform: hlw8012
model: HLW8012
# model: BL0937
# model (Optional, string): The sensor model on the board, to set internal constant factors to convert pulses to measurements. Possible values are HLW8012, CSE7759, BL0937.
# Defaults to HLW8012. CSE7759 uses same constants and it also works with default.
# Must be set for BL0937 to be able to calibrate all three measurements at the same time.
current_resistor: 0.001
voltage_divider: 2351
#(Optional, float): The value of the voltage divider on the board as (R_upstream + R_downstream) / R_downstream. Defaults to the Sonoff POW’s value 2351
sel_pin:
number: P26
inverted: True
cf_pin: P7
cf1_pin: P8
current:
name: "HLW8012 Current"
unit_of_measurement: A
accuracy_decimals: 3
filters:
# Map from sensor -> measured value
- calibrate_linear:
- 0.0 -> 0.0
- 0.83 -> 0.92
# - 1.34223 -> 1.066
# - 5.57170 -> 4.408
# - 6.69184 -> 5.259
# - 6.97187 -> 5.540
# # Make everything below 0.01A appear as just 0A.
# # Furthermore it corrects 0.013A for the power usage of the plug.
# - lambda: if (x < (0.01 - 0.013)) return 0; else return (x - 0.013)
voltage:
name: "HLW8012 Voltage"
unit_of_measurement: V
accuracy_decimals: 1
filters:
# Map from sensor -> measured value
- calibrate_linear:
- 0.0 -> 0.0
- 271.9 -> 221
- 272.6 -> 222.0
# - 609.8 -> 232.8
power:
name: "HLW8012 Power"
id: power
accuracy_decimals: 1
filters:
# Map from sensor -> measured value
- calibrate_linear:
- 0.0 -> 0.0
- 227.6 -> 205.0
# - 1503.27161 -> 247.6
# - 1599.81213 -> 263.7
# - 3923.67700 -> 631.4
# - 7109.50928 -> 1148.0
# - 7237.0857 -> 1193.0
# - 7426.71338 -> 1217.0
# # Make everything below 2W appear as just 0W.
# # Furthermore it corrects 1.14W for the power usage of the plug.
# - lambda: if (x < (2 + 1.14)) return 0; else return (x - 1.14);
energy:
name: "HLW8012 Energy"
update_interval: 2s
initial_mode: CURRENT
change_mode_every: 1
switch:
- platform: gpio
name: "Relay"
id: relay
pin: P24
# restore_mode: ALWAYS_OFF
on_turn_on:
then:
- light.turn_on: led
on_turn_off:
then:
- light.turn_off: led
binary_sensor:
- platform: gpio
pin: P6
name: "Tlačítko"
device_class: plug
on_press:
then:
- switch.toggle: relay
# status_led:
# pin:
# number: D0
# inverted: true
light:
- platform: status_led
internal: True
id: led
name: "Switch state LED"
pin:
number: P10
inverted: true
# restore_mode: ALWAYS_OFF