#Template light switched on by changing brightnes

1 messages · Page 1 of 1 (latest)

urban bay
#

Ok let me explain I have template light so that wall switch is being responsible for value template and levels are impported from light itself. For long time there was no problem for some reason it did not bother me in lovelance until setting up openHASP. I have noticed that 'light.turn_on' service itself can turn on such templated light (kind of obious). But when brightness parameter is given template it seems to be using service assigned in set_level. (again obvious) And this is wierd because setting brightness to 0 utilizes turn_off and I would expect setting any brightness other way around.

thin light
#

Still not following

#

you're saying using light.turn_on with that entity and a brightness of 0, that the light runs the service configured in turn_off:?

urban bay
#

it is true for both running service both inside DevTools and openHASP

thin light
#

second thing, set_temperature is not a thing for a light template

thin light
urban bay
#

I am not native speaker. But yes i do use little bit of english.

urban bay
thin light
#

ok, so yes or no to my previous question

thin light
urban bay
#

In short Yes. For clearance - I have not confirmed this by checking any debug logs. It is just after running service: light.turn_on data: brightness: 0 target: entity_id: light.goscinny switch assigned to templated light goes off.

thin light
#

there's nothing in the code that shows it will run the turn_off service if brightness is 0

#

it simply just runs the level script

#

hold tight, checking the level script code

urban bay
#

ok I will try to dive in events - have not done it in a while

thin light
#

well, that's it, there's nothing that would run the turn off service, so it must be something with your light

#

set your lights brightness to zero, not your template light.

#

bet you it's coming from that.

#

this

        service: light.turn_on
        data:
          entity_id: light.floalt_goscinny
          brightness: 0
urban bay
#

This does not turn off switch

#

and templated light is still visible as on with 0 brightness.

#

So it is as expected.

thin light
#

Not sure where it's coming from then, it's not called out in the code at all.

urban bay
#

I have confirmed that it is in fact calling for switch turn off in events. funny thing is that it actually runs both switch.turn_on and light.turn_on at the same time. https://postimg.cc/qhczJ0X9

#

Sanity check on other templated light also had same result.

urban bay
thin light
#

I already looked at that code. You can see the lightturn off service is not being called.

#

what you're showing there isn't the template light code

#

that's the base light class

urban bay
#

Ok I thought that template light utilize regular light services. I am not good at reading code, and do not want to insist but that line that I have pointed and https://www.home-assistant.io/integrations/light.template/#considerations < which from I understand points that this should work completly opposite to my case. So my thought is "something is not right. And Yes I have excluded everything that I could think off.

urban bay
#

ok I am still eager to debug this but i have taken things as simple as I could and redefined set_level: - service: switch.turn_on entity_id: switch.swiatlo_goscinny - service: light.turn_on data_template: entity_id: light.floalt_goscinny brightness: "{{ brightness | int(0) }}"

#

since it is turning off by itself it is all good now

thin light
urban bay
#

Can you point out what part of my explanation went so badly?

Ok, I am not so good at explaining things by writing. Give me another try.
I aimed to be able to completely manipulate light with just a slider referring to light brightness.

  1. Service light.turn_on w/ brightness set to '0' turns off switch templated in turn_off section (confirmed that with my colleague running different setup). *
  2. Issuing the same command without brightness (when the template entity is off) is turning on the switch.
  3. It is surprising that calling light.turn_on w/ brightness not being '0' on templated light is not able to turn on the switch by default. It seems to me that this behaviour would be more intuitive than that described in point 1 and surely lacks comapred to behaviour in point 2
thin light
#

if you want it to turn the light on when the light is off, add an if statement to your turn_on section that does that.