Hello
I am an average programer and I need some help please.
I have a problem that I thought would be easy but it appears to be difficult to solve. ( or I am making it hard)
I have a water tank level meter
I have 5 inputs. Full, 3/4, 1/2, 1/4, 0
Due to corrosion concerns I turn the power on to the level sensor for 10 sec, get the level reading and then turn it off.
When the power is on to this system I need to take the value that is read, either 5, 4, 3, 2, 1 and save it as a variable.
This is what I am struggling with.
I am using and ESPHome device to deliver these levels to HA.
I have tried an automation but I cannot get the value to stick.
Here is my code
When the switch.water_relay = ON
Then I need the sensor.water_tank_level value to be saved to sensor.water_tank_level_store_2
automation:
- alias: “Water tank Store 3”
trigger:
platform: state
entity_id: switch.water_relay
to: “on”
action:- service: input_number.set_value
target:
entity_id: input_number.water_level_stored
data:
sensor.water_tank_level_store_2: “{{ states(‘states.sensor.water_tank_level.state’) | int }}”
- service: input_number.set_value