Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PIng Apd. Home Assistant Automation Q.

35 views
Skip to first unread message

T i m

unread,
Feb 16, 2024, 5:57:24 AM2/16/24
to
Hi mate,

When playing with this HA thermostat project I found that I was
accidentally setting the temperature using the little Ikea (Zigbee)
dimmer switch whilst meaning to just turn it on or off.

This is process is currently done using 3 automations:

One to turn the virtual thermostat on:

alias: New Ikea long hold heater on
description: ""
trigger:
- device_id: d7801919c3628a93bbb9bb67b76594eb
domain: zha
platform: device
type: remote_button_long_press
subtype: dim_up
condition: []
action:
- service: climate.turn_on
metadata: {}
data: {}
target:
entity_id: climate.lounge
mode: single

One to turn it off:

alias: New Ikea long hold heater off
description: ""
trigger:
- device_id: d7801919c3628a93bbb9bb67b76594eb
domain: zha
platform: device
type: remote_button_long_press
subtype: dim_down
condition: []
action:
- service: climate.turn_off
target:
entity_id:
- climate.lounge
data: {}
mode: single

And a third that allows you to set the stat up or down 1 DegC:

alias: New Ikea up down temp
description: ""
trigger:
- device_id: d7801919c3628a93bbb9bb67b76594eb
domain: zha
platform: device
type: remote_button_short_press
subtype: turn_on
id: "1"
- device_id: d7801919c3628a93bbb9bb67b76594eb
domain: zha
platform: device
type: remote_button_short_press
subtype: turn_off
id: "-1"
condition: []
action:
- service: climate.set_temperature
metadata: {}
data:
temperature: "{{ state_attr('climate.lounge', 'temperature') +
trigger.id | int(0) }}"
target:
entity_id: climate.lounge
mode: single

What I tried to do was to add a condition to the Up/Down automation that
would only allow that to work if the stat was 'on' but I'm not sure we
have that state, just heating or idle so I tried to include those but
don't think the logic is right (eg, heating and idle can't be positive
at the same time, so I need an 'OR' in there somewhere?)

alias: New Ikea Up Down target temp test
description: ""
trigger:
- device_id: d7801919c3628a93bbb9bb67b76594eb
domain: zha
platform: device
type: remote_button_short_press
subtype: turn_on
id: "1"
- device_id: d7801919c3628a93bbb9bb67b76594eb
domain: zha
platform: device
type: remote_button_short_press
subtype: turn_off
id: "-1"
condition:
- condition: state
entity_id: climate.lounge
attribute: hvac_action
state: heating
enabled: true
- condition: state
entity_id: climate.lounge
attribute: hvac_action
state: idle
enabled: true
action:
- service: climate.set_temperature
metadata: {}
data:
temperature: "{{ state_attr('climate.lounge', 'temperature') +
trigger.id | int(0) }}"
target:
entity_id: climate.lounge
mode: single

So I think I found how to add that in the OR in the automation GUI:

alias: New Ikea Up Down target temp test or
description: ""
trigger:
- device_id: d7801919c3628a93bbb9bb67b76594eb
domain: zha
platform: device
type: remote_button_short_press
subtype: turn_on
id: "1"
- device_id: d7801919c3628a93bbb9bb67b76594eb
domain: zha
platform: device
type: remote_button_short_press
subtype: turn_off
id: "-1"
condition:
- condition: state
entity_id: climate.lounge
attribute: hvac_action
state: heating
enabled: true
- condition: or
conditions: []
- condition: state
entity_id: climate.lounge
attribute: hvac_action
state: idle
enabled: true
action:
- service: climate.set_temperature
metadata: {}
data:
temperature: "{{ state_attr('climate.lounge', 'temperature') +
trigger.id | int(0) }}"
target:
entity_id: climate.lounge
mode: single

But it doesn't seem to work? eg, I can still set the temp up and down
when the stat *isn't* 'heating' or 'idle'?

Any idea what have I missed please?

Cheers, T i m

David B.

unread,
Feb 16, 2024, 6:26:06 AM2/16/24
to
On 16 Feb 2024 at 10:57:18 GMT, "T i m" <ete...@spaced.me.uk> wrote:

> Hi mate,

Not Apd!

Might this be of help?

https://www.home-assistant.io/integrations/generic_thermostat/

--
David

David B.

unread,
Feb 16, 2024, 6:28:19 AM2/16/24
to
This was the source of that item:-
https://www.youtube.com/watch?v=9IiSgpHKt10

HTH

T i m

unread,
Feb 16, 2024, 6:49:40 AM2/16/24
to
No, sorry, you are *way* behind this particular curve, but thanks for
trying.

Cheers, T i m

p.s. I did pray that the code would work but it didn't so maybe I did it
wrong? ;-)

Apd

unread,
Feb 16, 2024, 8:40:24 AM2/16/24
to
"T i m" wrote:
> When playing with this HA thermostat project I found that I was
> accidentally setting the temperature using the little Ikea (Zigbee) dimmer
> switch whilst meaning to just turn it on or off.
>
> This is process is currently done using 3 automations:
>
> One to turn the virtual thermostat on:
[...]

> One to turn it off:
[...]

> And a third that allows you to set the stat up or down 1 DegC:
[...]

> What I tried to do was to add a condition to the Up/Down automation that
> would only allow that to work if the stat was 'on' but I'm not sure we
> have that state, just heating or idle so I tried to include those but
> don't think the logic is right (eg, heating and idle can't be positive at
> the same time, so I need an 'OR' in there somewhere?)
[...]

> So I think I found how to add that in the OR in the automation GUI:

[...]
> condition:
> - condition: state
> entity_id: climate.lounge
> attribute: hvac_action
> state: heating
> enabled: true
> - condition: or
> conditions: []
> - condition: state
> entity_id: climate.lounge
> attribute: hvac_action
> state: idle
> enabled: true
[...]

> But it doesn't seem to work? eg, I can still set the temp up and down when
> the stat *isn't* 'heating' or 'idle'?

Yes, that's not correct. The way to format the above entry is:

condition:
condition: or
conditions:
- condition: state
entity_id: climate.lounge
attribute: hvac_action
state: heating
enabled: true
- condition: state
entity_id: climate.lounge
attribute: hvac_action
state: idle
enabled: true

Alternatively, there's a shortened form:

condition:
or:
- condition: state
entity_id: climate.lounge
attribute: hvac_action
state: heating
enabled: true
- condition: state
entity_id: climate.lounge
attribute: hvac_action
state: idle
enabled: true


They both do the same thing. Whether they'll work or not is another
matter!


T i m

unread,
Feb 16, 2024, 9:48:53 AM2/16/24
to
On 16/02/2024 13:39, Apd wrote:

<snip>
>
> Yes, that's not correct. The way to format the above entry is:
>
<snip>
>
> Alternatively, there's a shortened form:
>
> condition:
> or:
> - condition: state
> entity_id: climate.lounge
> attribute: hvac_action
> state: heating
> enabled: true
> - condition: state
> entity_id: climate.lounge
> attribute: hvac_action
> state: idle
> enabled: true
>
>
> They both do the same thing. Whether they'll work or not is another
> matter!
>
>
Well, the second one (the only one I tried) worked first time so you are
now awarded the status of 'HA Automation Ace'! ;-)

It's also partly why I like the idea of being able to add such things
into my HA system and often the only way that can happen is with d-i-y
solutions like this (thermostat).

So thanks very much again Apd. It really make life just that little bit
easier. ;-)

Cheers, T i m


Apd

unread,
Feb 16, 2024, 11:40:39 AM2/16/24
to
"T i m" wrote:
> On 16/02/2024 13:39, Apd wrote:
>> They both do the same thing. Whether they'll work or not is another
>> matter!
>
> Well, the second one (the only one I tried) worked first time

<breathes a sigh of relief>

> so you are now awarded the status of 'HA Automation Ace'! ;-)

I dunno about that, having just looked it up. I was dreading how to
troubleshoot if it didn't work!

> It's also partly why I like the idea of being able to add such things into
> my HA system and often the only way that can happen is with d-i-y
> solutions like this (thermostat).
>
> So thanks very much again Apd. It really make life just that little bit
> easier. ;-)

YW. I don't know if you've seen these pages but it's where I found the
info:

<https://www.home-assistant.io/docs/automation/condition/>

Led to description of "or" from "full list of available conditions":

<https://www.home-assistant.io/docs/scripts/conditions/#or-condition>

I know they can be confusing, even to me, but no extra "code" had to
be added and it shows the pattern for the entry. Anyway, it's there
for future ref if it helps.


T i m

unread,
Feb 16, 2024, 1:15:42 PM2/16/24
to
On 16/02/2024 16:40, Apd wrote:
> "T i m" wrote:
>> On 16/02/2024 13:39, Apd wrote:
>>> They both do the same thing. Whether they'll work or not is another
>>> matter!
>>
>> Well, the second one (the only one I tried) worked first time
>
> <breathes a sigh of relief>

You are very modest.
>
>> so you are now awarded the status of 'HA Automation Ace'! ;-)
>
> I dunno about that, having just looked it up.

It doesn't matter how you got there, it was that you got there that
counts. ;-)

> I was dreading how to
> troubleshoot if it didn't work!

Meh, you would have nailed it.
>
>
> YW. I don't know if you've seen these pages but it's where I found the
> info:
>
> <https://www.home-assistant.io/docs/automation/condition/>
>
> Led to description of "or" from "full list of available conditions":
>
> <https://www.home-assistant.io/docs/scripts/conditions/#or-condition>

OOI, this it what it looks like as I would create it:

https://ibb.co/Lkbyzrt

If I expand one, you see this:

https://ibb.co/bzNk1TQ
>
> I know they can be confusing, even to me, but no extra "code" had to
> be added and it shows the pattern for the entry.

And the code you added can also be reviewed in the GUI form, unlike the
template used to deal with the up/down bit.

> Anyway, it's there
> for future ref if it helps.
>
The thing is, I'm so used to trying to deal with things from that sort
of level and getting nowhere, I rarely bother any more, unless it's
wholly useable as is or with some very obvious (to me) substitutions.


Cheers, T i m

Apd

unread,
Feb 16, 2024, 4:51:37 PM2/16/24
to
"T i m" wrote:
> OOI, this it what it looks like as I would create it:
>
> https://ibb.co/Lkbyzrt
>
> If I expand one, you see this:
>
> https://ibb.co/bzNk1TQ

If you created it via the GUI, then it didn't do a good job.

> And the code you added can also be reviewed in the GUI form,

So presumably you can compare it against what you did.

> unlike the template used to deal with the up/down bit.

As I understand.


T i m

unread,
Feb 16, 2024, 5:06:39 PM2/16/24
to
On 16/02/2024 21:51, Apd wrote:
> "T i m" wrote:
>> OOI, this it what it looks like as I would create it:
>>
>> https://ibb.co/Lkbyzrt
>>
>> If I expand one, you see this:
>>
>> https://ibb.co/bzNk1TQ
>
> If you created it via the GUI, then it didn't do a good job.

No, I mean that was the GUI representation of the code 'we' produced.
>
>> And the code you added can also be reviewed in the GUI form,
>
> So presumably you can compare it against what you did.

See above.
>
>> unlike the template used to deal with the up/down bit.
>
> As I understand.
>
Yes, so the point was 'your code' *could* be reverse represented by the
GUI whilst the template (some Geek on the HA forum) helped me with.

Ig, i could be possible for me to have produced what you did myself, but
using the GUI (if I knew the correct process).

I have had that before with the 'nesting' of the logic, where I was
adding something at the code root whereas it needed adding elsewhere.

Add code (and automation) in via the GUI and you can then view it in the
yaml editor and flip back and forth.

Code added directly in the yaml editor, may or may not be displayable in
the GUI.

Cheers, T i m

Apd

unread,
Feb 16, 2024, 6:16:35 PM2/16/24
to
"T i m" wrote:
> On 16/02/2024 21:51, Apd wrote:
>> If you created it via the GUI, then it didn't do a good job.
>
> No, I mean that was the GUI representation of the code 'we' produced.

I wondered if that was the case.

> Yes, so the point was 'your code' *could* be reverse represented by the
> GUI whilst the template (some Geek on the HA forum) helped me with.
>
> Ig, i could be possible for me to have produced what you did myself, but
> using the GUI (if I knew the correct process).
>
> I have had that before with the 'nesting' of the logic, where I was adding
> something at the code root whereas it needed adding elsewhere.

Ok. I thought you were more familiar with that GUI process than
perhaps you are.

> Add code (and automation) in via the GUI and you can then view it in the
> yaml editor and flip back and forth.

Useful, when you know what you're looking at.

> Code added directly in the yaml editor, may or may not be displayable in
> the GUI.

Yep.


T i m

unread,
Feb 17, 2024, 3:58:46 AM2/17/24
to
On 16/02/2024 23:16, Apd wrote:

<snip>

>> I have had that before with the 'nesting' of the logic, where I was adding
>> something at the code root whereas it needed adding elsewhere.
>
> Ok. I thought you were more familiar with that GUI process than
> perhaps you are.

Ah, no and no. ;-)

By that I mean not only am I not that familiar with the (more advanced)
GIO automation production, I'm not skilled re the logic in the first place.

I know 'what' I want to be but often don't understand the process needed
to make that happen.

Like, I noticed that I would often turn the stat on to find the target
temp had been (accidentally) set to something inappropriate and so have
to set it back. eg, I was having to fight the solution rather than it
making my life easier.

So I thought about doing something about that, considered an interlock
that restricted the ability to change the target temp when the stat was
off and then tried to implement it (and failed).

I had created the heater on and heater off automations unassisted (and
most of the others etc) because there were no conditions or there were,
but I could handle them (Like not having a light going on when it's
already sufficiently light because the light sensor entity was readily /
logically available ('When light level is above:') via the automation GUI).
>
>> Add code (and automation) in via the GUI and you can then view it in the
>> yaml editor and flip back and forth.
>
> Useful, when you know what you're looking at.

Quite, or want to see how some code entered via .yaml would look like in
the GUI (so you could do more yourself later etc).
>

Cheers, T i m

Steve Carroll

unread,
Feb 18, 2024, 11:25:40 AM2/18/24
to
On 2024-02-16, Apd <n...@all.invalid> wrote:
> "T i m" wrote:
>> On 16/02/2024 13:39, Apd wrote:
>>> They both do the same thing. Whether they'll work or not is another
>>> matter!
>>
>> Well, the second one (the only one I tried) worked first time
>
><breathes a sigh of relief>
>
>> so you are now awarded the status of 'HA Automation Ace'! ;-)
>
> I dunno about that, having just looked it up. I was dreading how to
> troubleshoot if it didn't work!

;)

>> It's also partly why I like the idea of being able to add such things into
>> my HA system and often the only way that can happen is with d-i-y
>> solutions like this (thermostat).
>>
>> So thanks very much again Apd. It really make life just that little bit
>> easier. ;-)
>
> YW. I don't know if you've seen these pages but it's where I found the
> info:
>
><https://www.home-assistant.io/docs/automation/condition/>
>
> Led to description of "or" from "full list of available conditions":
>
><https://www.home-assistant.io/docs/scripts/conditions/#or-condition>
>
> I know they can be confusing, even to me, but no extra "code" had to
> be added and it shows the pattern for the entry. Anyway, it's there
> for future ref if it helps.

Though possibly irritating to yaml 'purists', how the HA environment
allows for offloading of program 'logic/flow' to what appears to be
'yaml' but actually isn't (PyYAML doesn't know of these things) is a
pretty handy thing. This was obviously done for people who don't want to
learn 'programming' per se, to afford them limited access... filling the
wide gap between a programming language and the GUI.

Apd

unread,
Feb 19, 2024, 6:34:36 AM2/19/24
to
"Steve Carroll" wrote:
> Though possibly irritating to yaml 'purists', how the HA environment
> allows for offloading of program 'logic/flow' to what appears to be
> 'yaml' but actually isn't (PyYAML doesn't know of these things) is a
> pretty handy thing.

What do you mean about not being yaml? There are a few revisions of it
and I saw mention of an old syntax for yaml 1.0 but I don't know what
that might be.

> This was obviously done for people who don't want to learn 'programming'
> per se, to afford them limited access... filling the wide gap between a
> programming language and the GUI.

So it would appear. Yaml is described as a data serialization language
and it represents data structures. I'm not sure about the wisdom of
trying to use it as a substitute programming language.


T i m

unread,
Feb 19, 2024, 6:56:18 AM2/19/24
to
On 19/02/2024 11:34, Apd wrote:

> Yaml is described as a data serialization language
> and it represents data structures. I'm not sure about the wisdom of
> trying to use it as a substitute programming language.
>
FWIW, many non-programmers (and some programmers no doubt <g>) seem to
like 'Node-RED', 'a visual programming tool'.

https://nodered.org/

... add their GUI interface to the likes of Home Assistant as it's
supposed to make things easier.

https://mikehillyer.com/home-automation/getting-started-with-home-assistant-and-node-red/

I personally don't seem to get on with that style of 'programming /
scripting' but many do.

It's similar with the BBC micro:bit microcontroller / dev board a mate
gave me and outside installing a demo app, never really got to grips
with. But then with my ADHD I do seem to need fast reward V effort.

https://microbit.org/

I think I like some closer involvement in things, like I never had any
trouble ripping audio CD's and putting the resultant files onto an .mp3
player and so found the whole Apple 'We will do it all for you
automagically' very frustrating, *especially* when it went wrong.

I also wasn't a big enough music listener or photo taker to be too
bothered about having them organised in any automated way.

I think Node-RED is also some alternative firmware that can be installed
on the likes of the ESP32s.

Cheers, T i m


Apd

unread,
Feb 19, 2024, 8:54:36 AM2/19/24
to
"T i m" wrote:
> On 19/02/2024 11:34, Apd wrote:
>> Yaml is described as a data serialization language
>> and it represents data structures. I'm not sure about the wisdom of
>> trying to use it as a substitute programming language.
>>
> FWIW, many non-programmers (and some programmers no doubt <g>) seem to
> like 'Node-RED', 'a visual programming tool'.
>
> https://nodered.org/
>
> ... add their GUI interface to the likes of Home Assistant as it's
> supposed to make things easier.
>
> https://mikehillyer.com/home-automation/getting-started-with-home-assistant-and-node-red/
>
> I personally don't seem to get on with that style of 'programming /
> scripting' but many do.

I don't think I do. They call it flow-based programming which seems to
be based on message passing in flows of data. That's their "model"
which, if true for HA, might explain why the HA creator chose yaml.


Steve Carroll

unread,
Feb 19, 2024, 10:49:48 AM2/19/24
to
On 2024-02-19, Apd <n...@all.invalid> wrote:
> "Steve Carroll" wrote:
>> Though possibly irritating to yaml 'purists', how the HA environment
>> allows for offloading of program 'logic/flow' to what appears to be
>> 'yaml' but actually isn't (PyYAML doesn't know of these things) is a
>> pretty handy thing.
>
> What do you mean about not being yaml? There are a few revisions of it
> and I saw mention of an old syntax for yaml 1.0 but I don't know what
> that might be.

Aren't terms like "for:", "or:", "then:", etc. parsed by the HA
environment (not PyYAML)?

>> This was obviously done for people who don't want to learn 'programming'
>> per se, to afford them limited access... filling the wide gap between a
>> programming language and the GUI.
>
> So it would appear. Yaml is described as a data serialization language
> and it represents data structures. I'm not sure about the wisdom of
> trying to use it as a substitute programming language.

No, but given who uses HA, allowing for basic things isn't a bad idea.

Steve Carroll

unread,
Feb 19, 2024, 10:55:44 AM2/19/24
to
On 2024-02-19, Apd <n...@all.invalid> wrote:
Apparently, recent updates (within the last few years) to HA equates to
fewer reasons for NR's use (depending upon who is doing the
looking/using) but it still seems to be favored by many.

Apd

unread,
Feb 19, 2024, 12:54:53 PM2/19/24
to
"Steve Carroll" wrote:
> On 2024-02-19, Apd wrote:
>> "Steve Carroll" wrote:
>>> Though possibly irritating to yaml 'purists', how the HA environment
>>> allows for offloading of program 'logic/flow' to what appears to be
>>> 'yaml' but actually isn't (PyYAML doesn't know of these things) is a
>>> pretty handy thing.
>>
>> What do you mean about not being yaml? There are a few revisions of it
>> and I saw mention of an old syntax for yaml 1.0 but I don't know what
>> that might be.
>
> Aren't terms like "for:", "or:", "then:", etc. parsed by the HA
> environment (not PyYAML)?

Yes. They're keywords or names, particular to HA, used in conjuction
with others and which introduce lists. PyYAML shouldn't treat them as
having any special meaning, AFAIK.


Steve Carroll

unread,
Feb 19, 2024, 1:06:14 PM2/19/24
to
On 2024-02-19, Apd <n...@all.invalid> wrote:
On the other topic (Node Red), if this page is accurate...

<https://flowfuse.com/blog/2023/04/nodered-community-health/>

... it seems to still be growing (even if not on the HA platform... or
maybe it is?).

What's your main beef with it?

Mine isn't with the concept so much as the implementation... but maybe
there isn't an easier/better way to do it.

Apd

unread,
Feb 19, 2024, 2:37:21 PM2/19/24
to
"Steve Carroll" wrote:
> On the other topic (Node Red), if this page is accurate...
>
> <https://flowfuse.com/blog/2023/04/nodered-community-health/>
>
> ... it seems to still be growing (even if not on the HA platform... or
> maybe it is?).
>
> What's your main beef with it?
>
> Mine isn't with the concept so much as the implementation... but maybe
> there isn't an easier/better way to do it.

It may be good for its intended use but not my way of programming.
They give you the model (flow-based) and GUI widgets to help use it.
I want to decide my own model and don't want GUI objects for decision
making - that's what I write code for. The only GUI help I find useful
is for window creation, layout of buttons, selection boxes and such,
done by drag and drop and resizing with the mouse. All that
boilerplate is taken care of and you just set properties and call
their methods in code. They will have empty routines for events, like
"on_click", "on_change", etc, where you can write code to handle those
or ignore them as appropriate. Any "main" routine to tie them all
together is the program you write.


Steve Carroll

unread,
Feb 20, 2024, 11:11:46 AM2/20/24
to
On 2024-02-19, Apd <n...@all.invalid> wrote:
I agree. In any event, this 'no code' (OK... you can write code but may
not need to) approach is veering into 'commodity programming', so to
speak, and it's not likely to disappear.
0 new messages