See code below. What I am trying to do is determine when the valve is open or closed and NOT stuck in between. The valve has two limit switches. One for when the valve is closed and one for when it is open. One I get everything to work I will hide the two gpio binary sensors. The code passes the validate but dows not compile. I am a true novice but I love Home Assistant and refuse to give up. Any pointers would be welcome.
OK, I figured out most of what I was doing wrong. I needed to combine my if && statements by adding parenthesis. I also needed to remove the !state and use == true. The next problem I am running into is the compliler complaining about my return states not be declared in this scope.
config/esphome/basement-leak-detector.yaml: In lambda function:
/config/esphome/basement-leak-detector.yaml:127:16: error: 'closed' was not declared in this scope
return closed;
^~~~~~
/config/esphome/basement-leak-detector.yaml:127:16: note: suggested alternative: 'close'
return closed;
^~~~~~
close
/config/esphome/basement-leak-detector.yaml:129:16: error: could not convert 'open' from 'int(const char*, int, ...)' to 'esphome::optional<float>'
return open;
^~~~
/config/esphome/basement-leak-detector.yaml:132:15: error: 'null' was not declared in this scope
return null;
^~~~
/config/esphome/basement-leak-detector.yaml:132:15: note: suggested alternative: 'poll'
return null;
^~~~
poll
*** [/data/basement-leak-detector/.pioenvs/basement-leak-detector/src/main.cpp.o] Error 1
========================== [FAILED] Took 4.16 seconds ==========================
I would expect to see something before the first line… i.e. binary sensor etc.
Suggest you check that it will compile with just the valve_open and valve_close and check logs to ensure a value is showing up. Then build up the lambda slowly until you find the point it fails.
Somebody smarter than me might see the error… but not me…
Im JK!! Hey, it happens to all of at one point or another.
I didnt see anywhere were you mentioned the valve your using or posting a link to it… I assume it is a ball valve with 4 or 5 wires and outputs digital signals to show the valve state? Something like this?
Care to share any good or bad feedback on whichever valve you’re using?
esphome:
name: sonoff-4chpro-1
friendly_name: Sonoff_4CHPRO_1
##################### Note the 433MHz will not work at this time. Bummer but really no loss. DCT 3-13-2023
esp8266:
board: esp01_1m
It’s all good man and it better not ever happen again or else im going to send your manager a strongly worded letter that outlines my dissapointment and i may possibly just rage quit too!! ; ) lol
So, it sounds like everything is up and working correctly now?? It also sounds like you might have picked up that incurable illness of Smart Home Addiction too… Just be brave and keep fighting buddy!