I’m new to HA, but not new to programming or home automation in general.
I’m having trouble creating a simple automation that can make a decision based on the current value of some blinds that I’m automating that respond to a button push. (The button push part works great, but trying to do this via separate automations causes conflicts between them and incorrect results…so I’d rather have just one automation take care of it.)
Anyways, it’s a multi-use button push that, when the state is partially open (value 58), will tell the blinds to open fully (value 100) and vice versa. (I have other buttons on my remote for close, etc)
I’ve cobbled together this automation together based on going through the community forums and some of the docs, but it causes a config error when I reload it in HA. Not sure how to get this working. Any help would be appreciated, thanks!
Thanks for the help, the modified code help. I was trying different variations of things with > and >- and such last night with no luck.
Also, I had to put the “long-winded” code back because the shortened version would not fire with every button press of the same button. For this automation, it needs to fire every time any button is pressed, then it checks which one, and then the actions trigger based on the if then logic.
Ok, so one more quick thing. Based on the success of that automation running and the right code to make it work, I built two more automations to open and close the blinds in increments of 5 (scale of 0 to 100). The first one that does the addition works great, the one that does the subtraction doesn’t actually do the math for some reason. No error, it just doesn’t have the desired result (as in the blinds adjusting).
Any thoughts? (Again, need to keep them “long-winded” to make sure the automations fire every time the buttons are pressed) Thx all!
Alright, there was something strange about the 2nd automation that wasn’t working even after a correct copy and paste. I’m not sure what I did to fix it but it’s working now lol. Thanks all!
If you wish, you can streamline the data_templates in the two automations. It also improves their legibility.
For ‘Hue - Blinds Open By 5’
action:
- entity_id: cover.kitchen_1
service: cover.set_cover_position
data_template:
position: >
{% set p = state_attr('cover_kitchen_1', 'current_position')|int %}
{{ p + 5 if p <= 95 else p }}
For ‘Hue - Blinds Close By 5’
action:
- entity_id: cover.kitchen_1
service: cover.set_cover_position
data_template:
position: >
{% set p = state_attr('cover_kitchen_1', 'current_position')|int %}
{{ p - 5 if p >= 5 else p }}