YML light state after reboot keep setting to off... Is there a way to keep the same state that it had before reboot?

Hi guys
I have a mock light that I light up from apple homekit “when first person come home” and turn it down “when the last person leave home” these are super reliable automation from apple homekit that works flawlessly…

That is a great way to track that my home occupied.
I have a lot of automation in HA then attached to the state of that mock light.

Unfortunately the light turns off after HA reboot and that is pain.

Here is how the mock light is set up, just use a dummy script(script.mock_light_toggle) that does nothing:

I`m using light as it is the easiest way to trigger it form homekit.

#mock light for occupancy detection

  • platform: template
    lights:
    house_occupied_mock_light:
    friendly_name: “house_occupied”
    icon_template: mdi:home-outline
    unique_id: house_occupied_mock_light
    turn_on:
    service: script.mock_light_toggle
    turn_off:
    service: script.mock_light_toggle

Is there a an easy way to keep the state of YML light it after HA reboot?

Because the Template Light’s configuration is incomplete. It needs to employ the value_template option. That’s what’s used to report the Template Light’s current state .

You can use an input_boolean which is toggled everytime the template light is turn on or off and use the state as value_template for the light.

Awesome mate, did not know that i can just set up an input boolean and use it instead of a light. It also get passes to homekit as a switch. I can toggle it using native apple automation and its state is persistent during HA reboot of ! Thank you all sorted and home got a bit smarter !
Cheers