Switches turning on every day at sunrise but not supposed to

Hi

I am losing my mind over this please help!!!

I am using BG smart UK wall sockets, and for the most part they work as expected.

However I am having a very annoying issue, everyday at sunrise they are turning on but when trying to see why / what has caused this there is nothing in the log.


How is this possible and where can I find out what (I’m assuming that there is a buggy old bit of code somewhere) as I used to have this automated but changed it last summer when the sun was rising before we woke.

But ever since this has been happening (to some but not all of these switches)

Please be kind as I am fairly new to this!

In the device info page for your wall plug you can see what automatons or scenes the device is linked to. This will confirm if they are being called by HA to operate. If HA is not doing it it might be something set in the app you set them up in. Other than that I can’t help much.

As there is no context in the log (the “…turned on by…” bit) this means it is something outside Home Assistant that is turning on the switch. Home assistant is just reporting that something else caused the switch to turn on.

You can prove this if you want by shunting down home assistant before sunrise and checking what happens at sunrise.

1 Like

Do to have Alex or google Home, could it be a routine in one of those?

I can seem to remember Alexa asking me previously if I wanted it to setup a routine for me.

1 Like

@Jonah1970 No I have just checked this it’s not that…

@tom_l Thanks I will try this, although I don’t doubt what you are saying (it makes sense) but for the life of me don’t know what is doing it as I don’t have anything set up in either the broadlink app or Google home … . …

I will try this tonight and report back here after sunrise tomorrow!

@Arh yes I have looked here but unfortunately their is nothing here causing this problem.

I would suggest you turn on full debug or notset logs in configuration.yaml
restart ha and inspect the logs

logger:
  default: debug
#  default: warning

# critical
# fatal
# error
# warning
# warn
# info
# debug
# notset
1 Like

@_dev_null

Thanks I will do, am I looking in the log book or somewhere else?

@_dev_null

I have turn them on and I don’t see anymore information about why it turned on at sunrise 08:02:33 am…

If you’re unable to access the log directly

docker/homeassistant/config# tail -f home-assistant.log

Then download it from
Settings > System > Logs > Download full log

(word of caution : when enabling debug logs it’ll inflate the logfile size a fair bit)

@_dev_null

I have downloaded it, it’s a .bin file but I don’t see how to upload it here. I’m also unsure how to open it. Sorry :neutral_face: I’m not sure what drop-down is the correct one to select before downloading either.

Interesting, it should be a .log txt file which once downloaded should look like

home-assistant_2024-01-17T11-05-35.131Z.log

Either way you should be able to open it in a text editor

Never mind I found it!

1 Like

@_dev_null

Obviously there is no information on that ATM due to me not having it turned on this morning.

I will re download it tomorrow morning and post then. Thanks for the assistance so far!

Mike

@_dev_null

morning!

I have the following in the log at the time one of the switches turns on

Line 2529357: 2024-01-18 08:01:18.768 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=switch.livingroom_speaker_switch, old_state=<state switch.livingroom_speaker_switch=off; device_class=switch, icon=mdi:light-switch, friendly_name=Speaker Switch (Livingroom) @ 2024-01-17T23:51:15.769432+00:00>, new_state=<state switch.livingroom_speaker_switch=on; device_class=switch, icon=mdi:light-switch, friendly_name=Speaker Switch (Livingroom) @ 2024-01-18T08:01:18.768617+00:00>>
	Line 2529358: 2024-01-18 08:01:18.770 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140252155869248] Kitchen from 192.168.0.2 (Mozilla/5.0 (Linux; Android 11; Google Pixel Slate Build/R120-15662.64.0; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/120.0.6099.193 Safari/537.36 Home Assistant/2023.12.4-11898 (Android 11; Google Pixel Slate)): Sending [{"type":"event","event":{"c":{"switch.livingroom_speaker_switch":{"+":{"s":"on","lc":1705564878.768617,"c":{"user_id":null,"id":"01HMDSDDXGX69EMZ2DP4MBKMDM"}}}}},"id":2},{"type":"event","event":{"event_type":"state_changed","data":{"entity_id":"switch.livingroom_speaker_switch","old_state":{"entity_id":"switch.livingroom_speaker_switch","state":"off","attributes":{"device_class":"switch","icon":"mdi:light-switch","friendly_name":"Speaker Switch (Livingroom)"},"last_changed":"2024-01-17T23:51:15.769432+00:00","last_updated":"2024-01-17T23:51:15.769432+00:00","context":{"id":"01HMCXBY72TF7R9K0Q4E3AF7PC","parent_id":null,"user_id":"532c276b195f4f5899d92d2a7ead6292"}},"new_state":{"entity_id":"switch.livingroom_speaker_switch","state":"on","attributes":{"device_class":"switch","icon":"mdi:light-switch","friendly_name":"Speaker Switch (Livingroom)"},"last_changed":"2024-01-18T08:01:18.768617+00:00","last_updated":"2024-01-18T08:01:18.768617+00:00","context":{"id":"01HMDSDDXGX69EMZ2DP4MBKMDM","parent_id":null,"user_id":null}}},"origin":"LOCAL","time_fired":"2024-01-18T08:01:18.768617+00:00","context":{"id":"01HMDSDDXGX69EMZ2DP4MBKMDM","parent_id":null,"user_id":null}},"id":22}]
	Line 2529359: 2024-01-18 08:01:18.771 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: EventTask(event=<Event state_changed[L]: entity_id=switch.livingroom_speaker_switch, old_state=<state switch.livingroom_speaker_switch=off; device_class=switch, icon=mdi:light-switch, friendly_name=Speaker Switch (Livingroom) @ 2024-01-17T23:51:15.769432+00:00>, new_state=<state switch.livingroom_speaker_switch=on; device_class=switch, icon=mdi:light-switch, friendly_name=Speaker Switch (Livingroom) @ 2024-01-18T08:01:18.768617+00:00>>)
	Line 2529360: 2024-01-18 08:01:18.781 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140251363827520] Supervisor from 172.30.32.2 (HomeAssistantSupervisor/2023.12.1 aiohttp/3.9.1 Python/3.11): Sending [{"type":"event","event":{"event_type":"state_changed","data":{"entity_id":"switch.livingroom_speaker_switch","old_state":{"entity_id":"switch.livingroom_speaker_switch","state":"off","attributes":{"device_class":"switch","icon":"mdi:light-switch","friendly_name":"Speaker Switch (Livingroom)"},"last_changed":"2024-01-17T23:51:15.769432+00:00","last_updated":"2024-01-17T23:51:15.769432+00:00","context":{"id":"01HMCXBY72TF7R9K0Q4E3AF7PC","parent_id":null,"user_id":"532c276b195f4f5899d92d2a7ead6292"}},"new_state":{"entity_id":"switch.livingroom_speaker_switch","state":"on","attributes":{"device_class":"switch","icon":"mdi:light-switch","friendly_name":"Speaker Switch (Livingroom)"},"last_changed":"2024-01-18T08:01:18.768617+00:00","last_updated":"2024-01-18T08:01:18.768617+00:00","context":{"id":"01HMDSDDXGX69EMZ2DP4MBKMDM","parent_id":null,"user_id":null}}},"origin":"LOCAL","time_fired":"2024-01-18T08:01:18.768617+00:00","context":{"id":"01HMDSDDXGX69EMZ2DP4MBKMDM","parent_id":null,"user_id":null}},"id":2},{"type":"event","event":{"c":{"switch.livingroom_speaker_switch":{"+":{"s":"on","lc":1705564878.768617,"c":{"user_id":null,"id":"01HMDSDDXGX69EMZ2DP4MBKMDM"}}}}},"id":7}]
	Line 2529361: 2024-01-18 08:01:18.786 DEBUG (MainThread) [homeassistant.components.google_assistant.report_state] Scheduling report state for switch.livingroom_speaker_switch: {'online': True, 'on': True}

I have tbh I have no idea what I’m looking for/at.

Morning, yep I have a day job too :wink:

Assume the switch in question is

livingroom_speaker_switch

seems to have been turned on by this

Kitchen from 192.168.0.2 (Mozilla/5.0 (Linux; Android 11; Google Pixel Slate Build/R120-15662.64.0; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/120.0.6099.193 Safari/537.36 Home Assistant/2023.12.4-11898 (Android 11; Google Pixel Slate))

Maybe you have set this up in google home or something ?

That’s my tablet in my kitchen, do you or can you decifer if that command is coming from Google home on it or is it the home assistant app (I’m using browser mod on it) I mentioned this as I noticed that the screen also came on at the same time, this is shown as a “light” in HA for the purpose of turning it on and off.

It goes unavailable constantly and tbh is very buggy could this be the cause?

I have just uninstalled the home app (Google) from it as I never use it on here anyway.

Thanks for the help so far, don’t get caught at work :grin:

well, it’s not the tablet as it did it again today and the tablet is off.

Here are the logs from today

File "/usr/local/lib/python3.11/site-packages/imouapi/device_entity.py", line 601, in async_get_image
    raise InvalidResponse(f"unable to retrieve image from {url}: {exception}") from exception
imouapi.exceptions.InvalidResponse: unable to retrieve image from https://ali-pano-fk.oss-eu-central-1.aliyuncs.com/snappic/5K01315PAJAB974_img/Alarm/0/070e3cbb076744a5a4426ce95be3451c.jpg?Expires=1706255971&OSSAccessKeyId=LTAIyrmtqw10bcyQ&Signature=b2jyUvVI990qsqp3U0zkzeOUvxQ%3D: status code 404
2024-01-19 08:00:00.410 WARNING (MainThread) [homeassistant.components.google_assistant] No agent_user_id supplied for request_sync. Call as a user or pass in user id as agent_user_id
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 %}'
2024-01-19 08:00:12.901 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.0.199:7125 ssl:default [Connect call failed ('192.168.0.199', 7125)]
2024-01-19 08:00:30.335 WARNING (MainThread) [homeassistant.components.automation.music] Music: Already running
2024-01-19 08:00:53.427 WARNING (MainThread) [homeassistant.helpers.service] Referenced entities media_player.bedroom_ceiling_speakers_2 are missing or not currently available
2024-01-19 08:00:59.632 WARNING (MainThread) [homeassistant.components.switch.reproduce_state] Unable to find entity switch.games_room_audio
2024-01-19 08:01: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 %}'

Time offl sunrise today is 8:00:15 AM

you can see in the logs it’s complaining as it tried to turn on the tablet screen (it’s not supposed to do this either!)

Its like it has a mind of its own!

Any idea?

@_dev_null :neutral_face:

Hey,

I can’t see any reference in that log for

livingroom_speaker_switch

As mentioned by Tom, it appears to triggered by something outside of HA
It could be anything, Alexa routine, Google home, IFTTT or a tuya / smartlife schedule

What type of switch is it ? Have you looked at the app that came with it maybe that’s triggering it at sunrise or 8am