Trigger & Condition issue

Hi,

I’m having trouble getting my automation to work and am trying to troubleshoot it.

I would like the trigger to be when my phone connects to my home Wifi, I have given the phone a friendly name of “V30” and have set device tracker up - it correctly changes the status on the overview page when i connect / disconnect so i’m happy the tracker is working ok.

The condition I would like is that automation only works between the hours of 13:00 and 14:00.

The automation is an action on my harmony hub which shows up in the overview page and I can manually trigger.

My .yaml file is as follows -

automation:
  alias: 'Adam Lunch Droidbox'
  trigger:
    platform: state
    entity_id: device_tracker.V30
    from: 'not_home'
    to: 'home'
  action: 
    - service: remote.turn_on
      entity_id: remote.harmony_hub
      data:
        activity: "Watch PC"

I’d be really grateful if anyone can point out where i’ve gone wrong, apart from this being my 1st automation and me trying to run before I can crawl!

At the risk of sounding sarcastic, I think the main problem with your condition is that you haven’t actually put it in to your automation…

automation:
  alias: 'Adam Lunch Droidbox'
  trigger:
    platform: state
    entity_id: device_tracker.v30
    from: 'not_home'
    to: 'home'
  condition:
    condition: time 
    after: '13:00:00'
    before: '14:00:00'
  action: 
    - service: remote.turn_on
      entity_id: remote.harmony_hub
      data:
        activity: "Watch PC"

Apologies, I did initially have it in but removed it while I was just testing it to try and have the “from home to not home” trigger the automation.

I didnt have the seconds in the time condition thogh, would that make a difference?

Not sure, it is supposed to be ‘military time’ which is six digits, but some people seem to get things to work without the seconds in some circumstances.

Give it a punt and let us know :slight_smile:

Thanks for the suggestion but still no good.

I have changed the time condition to “from 13:00:0 to 23:00:00” so that its in-line with the current time.

I updated the .yaml file, restarted and then once fully booted I connected my phone to the wifi. The logbook picks up the state change of v30 from away to home but still doesnt fire the automation.

Is the automation switched on?

yes, its in the overview and toggle is set to on position. Also shows in the logbook as on, I connect to the wifi and logbook shows the state of the phone change but doesnt trigger the automation.

I can override and manually trigger it on the overview page
1
2
3

I get the above and then nothing

And the entity id of the device tracker is definitely device_tracker.v30?

yes, thats right.
4

I have tried the full name too (android83551c289018dc5a)

So no then, your entity_id is

device_tracker.android83551c289018dc5a

You can verify your entity_ids on the states page.

My bad, I was under the impression that once a friendly name was set that you could use either.

I’ve changed it to the long name but its made no difference :frowning:

You need to make certain that the entity id is correct in the automation, and then restart homeassistant. The automation itself is valid, it’s just the entity_id that is causing you problems.

All sorted now, thankyou very much for the help.

In the end I got rid of the friendly name in device tracker and put it back to “android83551c289018dc5a” and used the same in the trigger as it still wouldnt work with the friendly name in device tracker settings and the long name in the trigger.

working info in case anyone is stuck like i was

5

6

1 Like