Hi everyone, is it possible to get in ESPHome the current state of the cover ?
Not the position, I would like to get whether the cover is moving (closing of opening) or it is stopped.
I tried getting all the states I could think of I used a service to log the states in various situations, from the cover to the switches that move the curtain, but I don’t seem to be able to get anything usable.
My goal is to have a service in ESPHome , available in HA, so that I can mimic a open-stop-close-stop button, so to get this in ESPHome I would need to know what the cover is doing in the service of esphome, but I don’t seem to get anything apart from the position.
Not sure if there’s an easier way, but you can use a lambda call with the cover component to retrieve state internally. Then create a text sensor for ha, and use the lambda to set the text sensor to the matching state. The bottom of the esphome cover docs should be a good hint as to how to do this.
^disregard the above^
I realized you can only get current position that way (I think). So you might be able to do this with a cover template. It has ways to do up/stop/down commands directly.
what I’m trying to do is to end up with a single button to drive a open-stop-close-stop sequence, to do so I need to store the last direction of movement, so that’s why I would need to do this from inside esphome.
The problem I’m finding is that I can’t seem to find a reliable way to check and store the info in globals , because in esphome the only state I can consistently get is the actual position of the cover
An alternative, and IMO, more reliable way would be to use a Shelly 2.5 to manage the cover from HA or ESPHome and can be configured for 1 button operation, going through a Open>Stop>Close>Stop>Open> sequence with each button press.
Would you share some code ? I 'm having some real random results with globals in my time-based cover (I’m using a sonoff 4ch, which I think is not the problem), plus the .state is now flagged as deprecated when compiling
Sure. But I’m not trying to achieve, what you do. No use of global variables for example.
I have a shelly 2.5 that is connected to two physical momentary switches, one for up and one for down. In ESPhome, they are represented with a binary_sensor.
I see what you mean, infact my problem with globals is that I need to change them within the open/close/stop…_action part of the cover, to store the last movement direction, your lambda code is useful to stop the curtain midway, but it is still a two buttons control.
Whenever you press your switch, it should evaluate the current state and take the desired action. It shouldn’t be too difficult to adjust the conditions accordingly. I’m not even sure if global variables would be required at all, as you can refer to the current state.
The problem with the 1-botton control, is that when the cover is stopped, it should remember the direction of the last movement, because since it is stopped it has no way of telling if the next step should be open or close.