Why are some of my automations not triggering switches?

Using latest version of HA on Hassbian. Starting out trying some basic automation and its driving me insane!

Switches all work fine on manual activation and with Alexa (and with Alexa Groups too)

Automation problem 1:

- id: downstairs on
  alias: Turn on the lights when the sun sets
  initial_state: True
  hide_entity: False
  trigger:
    platform: sun
    event: sunset
    offset: "-01:00:00"
  action:
    service: switch.turn_on
    entity_id: switch.livingroom_led_light, switch.livingroom_lamp, switch.crystal_cabinet, switch.christmas_tree

This will run when triggered manually (at any time of the day, should it do this? Not had a sunset yet!), but switch.livingroom_led_light does not fire. It does not appear in the logbook where the other 3 do. Running the same automation with just this switch results in the same thing, no lights (switch is a Broadlink Pro RF command). The ‘off’ version of this automation results in the same.

Automation problem 2

- id: bedroom lamps on2
  alias: Turn on bedroom lamp
  initial_state: True
  hide_entity: False
  trigger:
    platform: time
    at: "12:05:00"
  action:
    service: switch.turn_off
    entity_id: switch.craig_lamp

Nothing happens when I run this. Running manually I get the automation trigger in the log but not the switch being fired. Nothing happens when it runs automatically, just appears in the log as triggered.

Automation problem 3

Using ‘after’ on ‘time’ platform like so:

  trigger:
    platform: time
    after: "12:05:00"

Given me the following error and I don’t know why as other people seem to be able to use it no problem:

Really confused on these errors. entity ID’s have been triple checked, and its not the brand of plugs as I have some working and some not working from both sets I use (and all work outside of automations)

Help!

OK, here goes.
1: Manually triggering (no surprise - by it’s very definition) by passes the trigger and gets on with the action :wink:
Can you show us the broadlink definition of the switch?

2: The id and the alias both say you are turning on the lamp, but you are actually turning it off :stuck_out_tongue: So if it’s already off it will stay off when triggered by automation or by manual trigger.

3: The docs state that you need to use at: not after:, to use after: you have to use it in conditions :slight_smile:

1: I suspected as much - sun has now set and it triggered the 3 switches just fine so that one works minus the dodgy switch.

Full Broadlink entry in configuration.yaml:

switch:
  - platform: broadlink
    host: mybroadlinkiphere
    mac: 'mybroadlinkmachere'  
    switches:
      tv:
        friendly_name: TV
        command_on: 'JgB4AAABKJQRFBETEjgRFBEUERQRExITETkROBITETkROBI4ETgSOBEUERQRFBE4EhMRFBEUERQROBE5ETgSExE5ETgSOBE4EgAFJwABKEkSAAxVAAEoShEADFUAAShKEQAMVQABKEoRAAxVAAEoShEADFUAAShKEQANBQ=='
        command_off: 'JgB4AAABKJQRFBETEjgRFBEUERQRExITETkROBITETkROBI4ETgSOBEUERQRFBE4EhMRFBEUERQROBE5ETgSExE5ETgSOBE4EgAFJwABKEkSAAxVAAEoShEADFUAAShKEQAMVQABKEoRAAxVAAEoShEADFUAAShKEQANBQ=='

      sound_bar:
        friendly_name: Sound Bar
        command_on: 'JgDMAFASKBMVEigTFBMoExUSFBMVEhUSFRIVEygSKBMUExUAAslQEigTFRIpEhQTKBMVEhQTFRIVEhUSFRIpEikSFRIVAALJUBIpEhUSKREWEigSFRIWERYSFRIVEhUSKRIoEhUSFgACyFERKRIVEikSFRIpEhUSFRIVEhUSFRIWESkSKRIVEhUAAslPEygTFRIpEhQTKBIVEhYSFRIVEhUSFBMoEygSFRIWAALJTxMoEhUSKBMVEigTFBMVEhUSFRIVEhUTKBIoExUSFQANBQAAAAAAAAAAAAAAAA=='
        command_off: 'JgDMAFASKBMVEigTFBMoExUSFBMVEhUSFRIVEygSKBMUExUAAslQEigTFRIpEhQTKBMVEhQTFRIVEhUSFRIpEikSFRIVAALJUBIpEhUSKREWEigSFRIWERYSFRIVEhUSKRIoEhUSFgACyFERKRIVEikSFRIpEhUSFRIVEhUSFRIWESkSKRIVEhUAAslPEygTFRIpEhQTKBIVEhYSFRIVEhUSFBMoEygSFRIWAALJTxMoEhUSKBMVEigTFBMVEhUSFRIVEhUTKBIoExUSFQANBQAAAAAAAAAAAAAAAA=='

      virgin:
        friendly_name: Virgin
        command_on: 'JgBCAB4dHhw6Ojs6OhweHR46Hhw6HR4AC5cfHB4cOjo8OTodHhweOh4cOh0eAAuYHhweHDw5Ojo7HB4dHjkeHTscHQANBQAAAAAAAA=='
        command_off: 'JgBCAB4dHhw6Ojs6OhweHR46Hhw6HR4AC5cfHB4cOjo8OTodHhweOh4cOh0eAAuYHhweHDw5Ojo7HB4dHjkeHTscHQANBQAAAAAAAA=='

      virgin_source:
        friendly_name: Virgin Source
        command_on: 'JgBIAAABIYwXEBQREzUUEBQRExEUEBQQFDUUNBMREzUUNBM1EzUUNBQREzUUNBM0FBEUDxQ0FDMUNRMRExITERQ1EzQTERQQEwANBQ=='
        command_off: 'JgBIAAABIYwXEBQREzUUEBQRExEUEBQQFDUUNBMREzUUNBM1EzUUNBQREzUUNBM0FBEUDxQ0FDMUNRMRExITERQ1EzQTERQQEwANBQ=='

      playstation_source:
        friendly_name: Playstation Source
        command_on: 'JgBQAAABJI8UEBMREjUVDxQQExETEBQREjUVNBQQFDQUNBQ0FTQTNRQQFBATNRM1FBATERM1EzUUNRM1ExETEBQ1EzUTERMREwAFIAABI0cTAA0FAAAAAAAAAAA='
        command_off: 'JgBQAAABJI8UEBMREjUVDxQQExETEBQREjUVNBQQFDQUNBQ0FTQTNRQQFBATNRM1FBATERM1EzUUNRM1ExETEBQ1EzUTERMREwAFIAABI0cTAA0FAAAAAAAAAAA='

      bedroom_tv:
        friendly_name: Bedroom TV
        command_on: 'skI0AAwdHgoLHR4KHwkfCR8KCx0LHQsdCx0MHQwdHgoLHQwcDB0LHQsdHwoeCR8JHwkfCQsAAToAAAAA'
        command_off: 'shs0AAsdHgoLHR4KHgoeCh4KCx0LHQsdCx0LHQsdHwoLHQsdCx0LHQwdHwoeCh8JHwkLHQsAATsAAAAA'

      craig_lamp:
        friendly_name: Craigs Lamp
        command_on: 'sh8yAAgSBxEHEgcSCBITBgcSEwYIEhQGCBITBgcSFAYIEhQFBxEHEhMGFAYIEQgREwYUBgi4AAAAAAAA'
        command_off: 'siMyAAgRCBEIEQgSBxITBgcREwYHEhMFCBEUBQgRFAYIERQGBxEIERQFEwYTBhMGCBEHEge4AAAAAAAA'

      julie_lamp:
        friendly_name: Julies Lamp
        command_on: 'siIyAAcSBxIHEgcSCBITBgcREwYHEhQGBxITBgcSFAYIEhMGEwYTBggSBxIHEgcSFAYUBge4AAAAAAAA'
        command_off: 'siEyAAgSBxIIEgcSCBETBgcSEwUIERQGBxITBgcSFAUIEhMGEwYTBgcRCBITBhMGBxIIEQe4AAAAAAAA'

      christmas_tree:
        friendly_name: Christmas Tree
        command_on: 'siQyAAcSBxIHEgcSBxITBgcSFAYHEhMGBxITBgcSEwYTBhMGBxIIEgcSBxIHEgcSEwYTBge4AAAAAAAA'
        command_off: 'shcyAAcSBxIHEQcSBxITBgcSEwYHEhMGBxEUBgcSEwYTBhMGBxIHEggRBxITBhMGBxIIEge4AAAAAAAA'

      fireplace:
        friendly_name: Fireplace
        command_on: 'sgoyAAcSBxIHEgcSBxITBgcSEwYHEhMGBxITBhMGEwYHEhMGBxIHEgcSBxIHEgcSEwYTBge4AAAAAAAA'
        command_off: 'sgwyAAcSBxIHEQcSBxITBgcSEwYHEhMGBxITBhMGEwYHEhMGBxIHEgcSBxITBhMGBxIHEgi4AAAAAAAA'

      livingroom_lamp:
        friendly_name: Livingroom Lamp
        command_on: 'shEyAAcSBxIHEgcSBxITBgcSEwYHEhMGEwYTBgcREwYHEhMGBxIHEgcSCBIIEgcSEwYTBge4AAAAAAAA'
        command_off: 'shsyAAcSBxIHEggSBxITBwcSFAYIEhMHEwYTBgcSEwYHEhMGBxIIEgcSBxITBhMGCBIHEge4AAAAAAAA'

      livingroom_main_light:
        friendly_name: Main Light
        command_on: 'sgDEAhcKFwkXChcJCxYXCQsWCxUYCRcKFwkXChcJFwoKFgwAAUngCgoWCxYXCRcKFwkYCRcJCxYLFQsWFwkLFgoWGAkLFRgJCxYXCRcKFwkYCQoWFwoKFgsWFwkYCRcJGAkXCRgJCxUNAAFI4QkLFgoWFwoXCRgJFwkYCQsVCxYLFRgJCxYKFhcJCxYYCQoWGAkXCRcKFwkLFhcJCxYKFhgJFwoXCRcJGAkXCQsWDAABSeAJCxYLFRgJFwkYCRcJGAkLFgoWCxUYCQsWChYXCgoWFwoKFhgJFwkYCRcJCxYXCgoWCxYX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oWCQwAAUnhCRYJCxUWCRcJChULFRYJFgoWCQsVFgkWCgoVFgoWCRYKChULFQoVFgoKFRYJCxULFAsVFgkLFQoVCxUWCRYKFgkMAAFJ4QkWCgoVFgkXCQsUCxUWCRYKFgkLFRYJFgoKFRYJFwkWCQsVCxQLFRYJCxUWCQsVChULFRYJCxUKFQsVFgkWChYJDAABSeEJFgkLFRYJFgoLFAsVFgkWChYJCxQXCRYJCxUWCRcJFgkLFQoVCxUWCQsVFgkLFQoVCxUWCQsVChULFRYJFgoWCQwAAUngChYJCxUWCRYKChULFRYJFgkXCQsUFwkWCQsVFgkWChYJCxUKFQsVFgkLFRYJCxUKFQsUFwkLFQoVCxQWChYJFwkMAAXc'

      livingroom_led_light:
        friendly_name: Back Lights
        command_on: 'sgc0ACcQJw8nDycPKA8nECcPJxAnDycPJxAnDycPJxAnDycQDigOKA4oDygOKScPDygOKA8AAZQAAAAA'
        command_off: 'sgY0ACgPKA8oDycPKA8nECgPKA8nDygPKA8oDygPKA8oDycPDygPKA8oDigPKA4oKA8OKA8AAZQAAAAA'

      livingroom_led_light_white:
        friendly_name: White Lights
        command_on: 'sgw0ACcPKA8oDygPJw8oDycPJw8nDycPJw8oDygPKA8nDycPDigPKA8oDigPKCcPKA8oDw8AAZQAAAAA'
        command_off: 'sgw0ACcPKA8oDygPJw8oDycPJw8nDycPJw8oDygPKA8nDycPDigPKA8oDigPKCcPKA8oDw8AAZQAAAAA'

      livingroom_led_light_blue:
        friendly_name: Blue Lights
        command_on: 'sgk0ACcPJw8oDygPJw8nDycPJxAnDycPKA8nDygPJw8nDycQDigOKA4oDygnDw8oJw8oDw8AAZQAAAAA'
        command_off: 'sgk0ACcPJw8oDygPJw8nDycPJxAnDycPKA8nDygPJw8nDycQDigOKA4oDygnDw8oJw8oDw8AAZQAAAAA'

      livingroom_led_light_purple:
        friendly_name: Purple Lights
        command_on: 'sgs0ACgPKA8oDygPKA8oDygPKA8oDygPKA8nDygPKA8oDygPDygPKA8oKA8PKCgPKA8oDw8AAZQAAAAA'
        command_off: 'sgs0ACgPKA8oDygPKA8oDygPKA8oDygPKA8nDygPKA8oDygPDygPKA8oKA8PKCgPKA8oDw8AAZQAAAAA'


      crystal_cabinet:
        friendly_name: Crystal Cabinet
        command_on: 'sgw0AAwcHwoLHR8JHwkfCR8JDB0MHQwdDB0MHQwdHwoLHQwcCx0MHQscHwkfCR8JDB0fCQwAATsAAAAA'
        command_off: 'sgk0AAsdHwkMHB8JHwkfCR8JDBwMHQsdDB0MHAsdHwoLHAwdDB0MHQwdHwofCh8KCx0MHAsAAToAAAAA'

      kettle:
        friendly_name: Kettle
        command_on: 'sgw0AAsdHwkLHR8JHwkfCR8KDB0MHQwdCx0MHQscHwoLHQwcCxwMHQwdHwkfCQwdHwkfCQsAATsAAAAA'
        command_off: 'shQ0AAsdHwoLHB8JHwkfCR8JDB0MHQwdDB0MHQwdHwoLHQwcCxwLHQwdHwkfCQwdHwkMHQwAATsAAAAA'

To note - the livingroom_lamp switch is Generic Brand A and works in the automation - the craig_lamp is also from this set and does not.

2: Sorry, that was me playing around and testing if it was something to do with .on. Still fails to turn off or register it in the log either way round.

3: That makes sense. Where can I find the doc for ‘time’? I hunted for it but couldn’t find anything myself.

EDIT: Some further testing. I added the craig_lamp and julie_lamp to the partially working first automation. They still do not turn on or register in the log as having been called, where as the 3 working ones still do.

The working livingroom_lamp is the same brand as these 2, and the RF code seems to be the same length. They are formatted identically in the switches section, and there are no extra spaces etc hidden in there. I’m stumped as to why they are find when asked for but fail when automated.

1: switch.livingroom_led_light put a couple of == at the end of the definition so it becomes 8AAZQAAAAA==’
same for craig_lamp

2: https://home-assistant.io/docs/automation/trigger/

Cheers for the link :slight_smile:

The config fails without defining them as switches with the switch. prefix. switch.crystal_cabinet doesn’t exist in that format either but works, its just crystal_cabinet.

Yep sorry I was look at the friendly name :P, however a common error with the broadlink is that they need a couple of == at the end of the definition to complete the signal.

I suspected it might be that, I’ll give it a go next. Just about to test if doing it with a group gets any different results. Thanks, will update shortly!

new groups.yaml config:

default_view:
  name: default
  view: yes
  entities:
    - group.evening_lights

evening_lights:
  name: evening lights
  entities:
    - switch.livingroom_lamp
    - switch.livingroom_led_light
    - switch.crystal_cabinet
    - switch.christmas_tree

The livingroom_led_light does not appear in the GUI box, has to be something to do with the switch entry. Trying the == now.

== no good either. code still works manually. Name of switch changed, still nothing. I think something in HA is stopping the automation ‘seeing’ the entry for the switch.

Copied the christmas_tree switch RF codes in over the livingroom_led_lights and it refuses to turn the christmas tree on under that name, so its not the codes that are the problem here, something in HA is making it gloss over switches in certain positions in the switch list.

Going to try putting the livingroom_led_lights entry in the position the christmas_tree currently is.

EDIT: No change, still not working when the list was re-shuffled. I am out of ideas.

Can you try the friendly name making sure you change any spaces for ‘_’ and any capitals for lowercase?

Have a look in the state table for the ones playing up.

Tried the friendly names change - no good.

Created a new config with just the 1 bad switch and the automation, still doesn’t work:

switch:
  - platform: broadlink
    host: 192.168.0.32
    mac: '34:EA:34:C7:85:42'  
    switches:
      livingroom_led_light:
        friendly_name: back_lights
        command_on: 'sgc0ACcQJw8nDycPKA8nECcPJxAnDycPJxAnDycPJxAnDycQDigOKA4oDygOKScPDygOKA8AAZQAAAAA=='
        command_off: 'sgY0ACgPKA8oDycPKA8nECgPKA8nDygPKA8oDygPKA8oDycPDygPKA8oDigPKA4oKA8OKA8AAZQAAAAA=='

automation:
- id: downstairs on
  alias: Turn on the lights when the sun sets
  initial_state: True
  hide_entity: False
  trigger:
    platform: sun
    event: sunset
    offset: "-01:00:00"
  action:
    service: switch.turn_on
    entity_id: switch.livingroom_led_light

Nothing strange in the state table:

switch.back_lights off assumed_state: true
friendly_name: back_lights

Totally lost now!

Notice how it’s called back_lights NOT livingroom_led_light

So…

automation:
- id: downstairs on
  alias: Turn on the lights when the sun sets
  initial_state: True
  hide_entity: False
  trigger:
    platform: sun
    event: sunset
    offset: "-01:00:00"
  action:
    service: switch.turn_on
    entity_id: switch.back_lights

Son of a…

Do they drink beer by the keg where you are from Keith? Think I owe you one!

Working perfect. I made the assumption (I would argue the logical one!) that it would call the name of the switch, not a modified friendly name. Sometimes I love and sometimes I loathe HA.

Thanks again for all the help man!

Yep HA does that sometimes, that’s why you have to look in the states table for the name, it’s not always what you expect :wink: