Referenced entities switch.elektrische_deken_2_socket_1 are missing or not currently available

I know there are more similar topics but in those I didn’t find a solution for my problem:

I have two automations to control a smart socket (Tuya-WOOX) that is connected to an electric blanket. In the first one the trigger is a button-press (Zigbee) and the action the toggle of the smart socket. This works, also when I am standing next to the socket with the button in my hand [my conclusion: both are within reach (Zigbee/WiFi)].
In the second one the trigger is a point of time (05:00:00) and the action is the switching off of the same smart socket. This one doesn’t work and generates an error message (see title) in the log file.

Yaml of the first automation:

alias: Knop 7 - Electric Blanket - Toggle
description: ""
triggers:
  - domain: mqtt
    device_id: 47a8a4ef7873572d8a0c9081b60e05fc
    type: action
    subtype: single
    trigger: device
conditions: []
actions:
  - type: toggle
    device_id: 0c7063d8c3cf394cc0e944f0e2863fcb
    entity_id: 172c8be6b4e60dedfae3adca82f7c273
    domain: switch
mode: single

Yaml of the second automation:

alias: Electric Blanket 05:00 - OFF
description: ""
triggers:
  - trigger: time_pattern
    hours: "05"
    minutes: "00"
    seconds: "00"
conditions: []
actions:
  - type: turn_off
    device_id: 0c7063d8c3cf394cc0e944f0e2863fcb
    entity_id: 172c8be6b4e60dedfae3adca82f7c273
    domain: switch
mode: single

In both cases the actions are similar, so I don’t understand why the action in the second automation gives an error message.

Check the history of your entity. If it’s going unavailable when your automation fires, then the action will fail.

There are two other issues I can see with your automation:

First one is an inconsistency - you’re using toggle to switch on, but turn_off to switch off. Try using toggle for both (and have a condition to check the state), or else use turn_on for your first automation.

Second issue is your trigger in the second automation - you’re using a time_pattern trigger, but what you really want is a time trigger. Learn the difference between the two or it might cause you issues down the line.

Finally, if you’re just starting out, I suggest you read this Why and how to avoid device_ids in automations and scripts. Again, learning this at this stage while you’re just starting out will help you avoid issues down the line.

Thanks for your response. As both actions are valid (I think), I don’t understand why it should make a difference for the automation. But I will try it out. And I will certainly follow your other advises. I haven’t changed the automation, but for one or other reason this morning it worked. In between there was an update of HA, but I don’t really think that had any influence.

Check the history of your smart socket for the past week. I suspect it’s randomly going unavailable and you were lucky enough that it was available this morning when the automation fired at 5.

I checked the history already before and the entity is not going randomly unavailable, but only was missing at the time the automation fired. For what reason could it go randomly unavailable?

It could go unavailable for a number of reasons. In no particular order:

  • Network issues, such as low WiFi signal, changes in IP or your router set to automatically reboot at around 5 am
  • Cloud disconnection issue if you’re using the Tuya integration. They’re not exactly known to be reliable.
  • Power or temperature issues. Electric blankets draw a fair amount of power. Your plug might be rated at the very edge of this power, causing it to heat up over time & disconnect or shutdown.

Obviously the above are just assumptions based on the info you provided so far, but they are all valid possibilities. You will need to figure out what is causing the disconnect yourself

Thanks for the information. Indeed I am using the Tuya integration and also the strength of the WiFi isn’t great there. And this afternoon it is getting “unavailable” every 20 minutes or so. So I will look in that direction to improve things. Again, thanks for helping.

1 Like

Given you already have a zigbee mesh going, may I suggest you get a zigbee plug instead?

It will serve as a router and will strengthen your zigbee mesh, provided you have decent connectivity in that room.

Good advise. The reason I use a WOOX smart switch is that I already owned 2 of these.

I studied the time trigger and the time pattern. They only differ in the number of variations that are available to specify the trigger-times. I don’t see how using the time-trigger might cause me issues?

In this particular case, it won’t cause you issues. There’s only 1 time pattern which matches hours: 5, and that’s 5am.

I was simply trying to warn you in case you do a similar automation where the time_pattern could match multiple times. Easier to get used to it now rather than have it cause you issues down the line.

PS: Note the warning below time_pattern in the docs too:
“Do not prefix numbers with a zero - using '01' instead of '1' for example will result in errors.”

1 Like

I didn’t choose this time_pattern trigger, it was ‘created’ by the GUI. And thanks, I already red that warning.