Switches turning on every day at sunrise but not supposed to

Hello

It’s a Broadlink driven British General smart socket.

It’s not coming from the app there is nothing set in it at all.

I used to have a routine in HA that turn on at sunrise but this has been removed.

It’s not turning on at 8 am it tracking the sunrise backwards as we head into summer.

I’m totally at a loss as to what is causing this. It’s definitely the sun rise trigging it so it must be from within HA as the app is totally absent of anything, and additional I have never used the app to do anything but set it up.

I don’t have Alexa and their is no trigger coming from Google I ha e triple checked this ther isn’t anything there.

I’m stumped :thinking:

Nope.

Also is this anything to do with what switches your switch?

2024-01-19 08:00:00.454 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'None' has no attribute 'state' when rendering '{% if now().hour > 22 and now().hour < 8 and states.sensor.date_time.state%}
  {{states.sensor.livingroom_temperature.state}}
{% elif states.sensor.date_time.state %}
  {{states.sensor.bedroom_temperature.state}}
{% endif %}'

Because at the moment it is probably not doing what you expect.

https://www.home-assistant.io/docs/configuration/templating/#states

So something like this is syntactically (though not logically) a better option:

{% now().hour > 22 and now().hour < 8 and states('sensor.date_time') %}
  {{states('sensor.livingroom_temperature') }}
{% elif states('sensor.date_time') %}
  {{states('sensor.bedroom_temperature') }}
{% endif %}'

The remaining problems with that template:

  1. There is no else case. Jinja if testes require an else case.
  2. This makes no sense:

and states('sensor.date_time')

Likewise I am not sure what you are trying to accomplish here:

elif states('sensor.date_time')

If this is unrelated to your switch on issue would be best if you opened a new topic about this template (sensor?) explaining what you are trying to accomplish.

Check automation.yaml file for your previous automation. It might not visible in the GUI, however still working.

If it was an automation there would be context in the log.

Agree, but orphan automations might have other errors, than not showing up in GUi. It is actually a long time since I experienced the error of automations not showing in GUI, might be a old problem.

The more I look at it the more I think this template is the issue (see the 8am time?):

 '{% if now().hour > 22 and now().hour < 8 and states.sensor.date_time.state%}
  {{states.sensor.livingroom_temperature.state}}
{% elif states.sensor.date_time.state %}
  {{states.sensor.bedroom_temperature.state}}
{% endif %}'

@miketarg :point_up: I think Tom and khvej8 are onto something …

If it’s an automation or an orphaned one, could it still be found in the /config folder ?

Search for ‘8 and states.sensor.date_time’ in all the files

From the SSH terminal

cd /config 
grep -R '8 and states.sensor.date_time' *

or maybe you can try searching through a backup or the filesystem if you have direct access to it

Fixed by removing and resetting the plugs in question within the broadlink app.

Good job, thanks for letting us know

1 Like