Skip to content

Instantly share code, notes, and snippets.

@malinovsku
Created December 11, 2022 17:47
Show Gist options
  • Save malinovsku/418b20e4069cbc397cd550534cb8c643 to your computer and use it in GitHub Desktop.
Save malinovsku/418b20e4069cbc397cd550534cb8c643 to your computer and use it in GitHub Desktop.
sensor:
- platform: hx711
dout_pin: 14
id: sensor_hx711_d
name: ${device_name2}
unit_of_measurement: "%"
clk_pin: 5
gain: 128
update_interval: 1s
filters:
- calibrate_linear:
- 751931 -> 0
- 2431100 -> 100
- lambda: return int(x);
on_value:
then:
- if:
condition:
lambda: |-
return id(prev_value) != x;
then:
- globals.set:
id: prev_time
value: '0'
- if:
condition:
lambda: |-
return id(prev_value) > x;
then:
- lambda: |-
id(sensor_nabor).publish_state({"Слив воды"});
else:
- lambda: |-
id(sensor_nabor).publish_state({"Набор воды"});
- lambda: |-
id(prev_value) = x;
interval:
- interval: 500ms
then:
- if:
condition:
lambda: |-
return id(prev_time) < 65;
then:
- lambda: |-
id(prev_time) += 1;
text_sensor:
- platform: template
name: nabor_${device_name2}
id: sensor_nabor
entity_category: ''
icon: "mdi:propane-tank-outline"
lambda: |-
if (id(prev_time) > 60) {
return {"Бак полный"};
}
else {
return id(sensor_nabor).state;
}
update_interval: 1s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment