Triggering an automation early then the specified time

so I used this {{ states.sensor.manutd.state == states.sensor.time.state }} but I get the following error :

2017-10-20 15:24:20 ERROR (Thread-2) [homeassistant.util.yaml] while scanning for the next token
found character '\t' that cannot start any token
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 68, column 1
2017-10-20 15:24:20 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: while scanning for the next token
found character '\t' that cannot start any token
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 68, column 1

Line 68 is {{ states.sensor.manutd.state == states.sensor.time.state }}

Don’t use tabs, you have to use spaces

2 Likes

I know some of us sound like a broken record, but why is the timing so critical that 8 seconds is a problem? What specifically are you trying to do?

This is an important question, because some user might have a good way to accomplish what you want, but without the struggles and complications you’re having now. :slight_smile:

It might be easier to modify the python script to output the correct format like json or use mqtt. He is using this script.

Right that sorts that out.

Sorry for my novelty but do I expect to see the binary sensor on the front end? I have tried looking for it as a senor in the states page but cannot see it. I have done a test run when the sensor.manutd is equal to sensor.time.

You should see it in the dev-states view (<>), whether you see it elsewhere depends on your configuration.

If you don’t see binary_sensor.test_up it suggests that it hasn’t loaded. Use hassctl to test your configuration.

1 Like

Hey @Dolores, @RobDYI has just explained what I am trying to achieve.

If anyone of you could please try to use the time component the way I have used it, you might actually see what I am trying to explain all this time (and the lag).

The lag is important because the time component is not in sync in general with HA and it defeats the purpose really of having a “time” component.

The trouble is, Home Assistant isn’t a real time platform and doesn’t pretend to be one. There’s always going to be delays, even when everything is purely internal to the system you’re running it on. Using a template like that slows things down again, and may well be the primary source of the delay.

The best you’re likely to achieve is to identify the typical range, and instead set it to trigger one minute earlier, then have a delay of (say) 52 seconds. That’s horribly, horribly, inefficient, but it may achieve what you’re after.

My purely time based automations generally fire within 2 minutes of the designated time (so, if due to trigger at 06:00 they’ll trigger between 06:00 and 06:01 inclusive).

2 Likes

Binary sensor sorts it out thanks ever so much @Tinkerer. Must admit your automation knowledge is pretty damn good mate. Cheers!!