Automation Actions don't run when triggered by time

Hello there! :slight_smile:

I have an automation to turn the switch on a Tuya Smart Power Strip on at a specific time in the morning. Unfortunately, this does not seem to work all the time and instead - seemingly - randomgly does not actually perform the actions in the automations. Looking at the history, I can see the Automation triggering from time, but then seemingly not actually turning the switch on:

If I run it manually, it works fine:

There is no entry in the error logs around the time of triggering and I used the UI to create the automation. Still, here’s the yaml as well:

alias: Plant Light Morning
description: ''
trigger:
  - platform: time
    at: '08:00:00'
condition: []
action:
  - type: turn_on
    device_id: eb1aa22e5f6c32ab6284c699e18e63d0
    entity_id: switch.smart_power_strip_socket_3
    domain: switch
mode: single

What do the various (date/time) show trace present ?

Thanks for the reply! I hope this is the right thing - I downloaded the log in it’s entirety from the page.

{
  "trace": {
    "last_step": "action/0",
    "run_id": "337608de2a9028bf9f922d7f2269c27d",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2022-07-18T06:00:00.002405+00:00",
      "finish": "2022-07-18T06:00:07.130169+00:00"
    },
    "domain": "automation",
    "item_id": "1657827646039",
    "trigger": "time",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2022-07-18T06:00:00.002604+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.plant_light",
              "state": "on",
              "attributes": {
                "last_triggered": "2022-07-17T06:00:00.002781+00:00",
                "mode": "single",
                "current": 0,
                "id": "1657827646039",
                "friendly_name": "Plant Light Morning"
              },
              "last_changed": "2022-07-15T19:40:08.086143+00:00",
              "last_updated": "2022-07-17T06:00:07.128361+00:00",
              "context": {
                "id": "01G85BW6PR7QAZKZN1YZ7BJJ9Y",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "platform": "time",
              "now": "2022-07-18T08:00:00.001511+02:00",
              "description": "time",
              "entity_id": null
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2022-07-18T06:00:00.009771+00:00",
          "changed_variables": {
            "context": {
              "id": "01G87Y8PR2Q7WDJ3EESX48NG0J",
              "parent_id": null,
              "user_id": null
            }
          }
        }
      ]
    },
    "config": {
      "id": "1657827646039",
      "alias": "Plant Light Morning",
      "description": "",
      "trigger": [
        {
          "platform": "time",
          "at": "08:00:00"
        }
      ],
      "condition": [],
      "action": [
        {
          "type": "turn_on",
          "device_id": "eb1aa22e5f6c32ab6284c699e18e63d0",
          "entity_id": "switch.smart_power_strip_socket_3",
          "domain": "switch"
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01G87Y8PR2Q7WDJ3EESX48NG0J",
      "parent_id": null,
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Plant Light Morning",
      "message": "triggered by time",
      "source": "time",
      "entity_id": "automation.plant_light",
      "context_id": "01G87Y8PR2Q7WDJ3EESX48NG0J",
      "when": 1658124000.002981,
      "domain": "automation"
    }
  ]
}

Try to get insight if at least the aytomation runs and ends…it may send the ‘on’ to the lamp but the lamp might not be responding

And also try to see if your device (switch.smart_power_strip_socket_3) is doing something (logbook entries).
What happens when you switch it on manually (via HA > Developer Tools > States you can set the value manually)

The plant light has no Logbook entries for the time-triggered automation, but it does have one for the manual triggering.

For the one triggered by time, I can see the following for the first step:

this:
  entity_id: automation.plant_light
  state: 'on'
  attributes:
    last_triggered: '2022-07-17T06:00:00.002781+00:00'
    mode: single
    current: 0
    id: '1657827646039'
    friendly_name: Plant Light Morning
  last_changed: '2022-07-15T19:40:08.086143+00:00'
  last_updated: '2022-07-17T06:00:07.128361+00:00'
  context:
    id: 01G85BW6PR7QAZKZN1YZ7BJJ9Y
    parent_id: null
    user_id: null
trigger:
  id: '0'
  idx: '0'
  platform: time
  now: '2022-07-18T08:00:00.001511+02:00'
  description: time
  entity_id: null

And the second step:

context:
  id: 01G87YB1XZCWAJ4YDNRTW4K838
  parent_id: null
  user_id: null

I can however see that the manually triggered one has a parent ID, which the time-triggered one doesn’t have:

context:
  id: 01G87YB1XZCWAJ4YDNRTW4K838
  parent_id: 01G87YB1XXXNCZACH65CRWAVJT
  user_id: null

Triggering it in the Developer Tools by setting the status to on, off, On or Off, nothing happens.

And if you tick ‘Run Actions’ to test the automation, does it switch-on the lamp?

Yes, in that case the lamp is switched on correctly. Same if I do it in the Lovelace-Interface.

I have the same issue with a Tuya light-strip. The automation seems to work, and it runs to the end - but the light is not turned on. The trace says it turns on the light.
If I edit the automation (change something, like the brightness) - it works one time again, but not the next time. :confused:
If I run the automation manually (just the action), it works.

I have another automation to turn off the light, that works every time.
If I try to turn on/off the light manually, it works every time.

I changed to use scene (not “device - turn on”) yesterday, so I will see today if that does something different…

Hmm, indeed you automations seems A-OK to me, using a very similar one myself.
Does the device have multiple ways to turn on? e.g. I have this for my tuya lightstrip and only one works fine

It really only seems to have on/off and toggle. For the most part, it’s a very simple device.

This could be a general Tuya bug however, as I see some reports like this in the bug tracker:

And btw… my tuya lights strips are under domain ‘light’ (tuyalocal)…no clue if that would change a things though, for me this should just work as you wrote it (now leaving home as on holidays)… hope someone else has good ideas

I’ll switch the switch to the light domain and see if that does anything. :slight_smile:

That doesn’t seem to have done anything. Mh… Maybe I’ll try switching it all to local Tuya and see if that works better.

It is weird, the automation is dead simple and manually it works. What I am missing in the log is a section action/1. So maybe the time 00:00:00 is frustrating it, did you try to run it on a normal daytime slot, e.g. in 2 minutes from your ‘now’ ?

Yeah, I added +3 Minutes to it and it didn’t help either - I did switch to local Tuya now tho, away from the official Tuya, and that seems to be working!

I don’t think it’s a Tuya only problem. I’m having the same issue with a Sonoff BASIC R3.