Damned condition Time

I try to enable a IR motion detector between 21h00 and 07h30… I tried a lot of time manipulations, but no ones works. That seems a very easy task to do but it become a nightmare to get it work.

First I tried the very easy way:

- id: '1570472441280'
  alias: Wall side Entry IR
  trigger:
  - entity_id: light.wswside_ir
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - condition: time
    after: '21:00:00'
    before: '07:30:00'
  action:
  - alias: ''
    data:
      entity_id: light.wswside
    service: light.turn_on
  - data:
      entity_id: timer.side_entry
    service: timer.start

It don’t work then I tried:

  condition:
    condition: and
    conditions:
      - condition: time
        after: '21:00:00'
      - condition: time
        before: '07:30:00'

Then may be it was not enough, then I tried:

  condition:
    condition: and
    conditions:
      - condition: time
        after: '21:00:00'
        before: '23:59:59'
      - condition: time
        after: '00:00:01'
        before: '15:30:00'

Gees it still not work… I don’t know what else I can do, that’s become funny… simple task, big nightmare!

change it to ‘or’. You can’t be simultaneously before 7:30 and after 21:00 in the same day. It’s one OR the other.

EDIT: As a side note, your first one will work without changing the condition. You should check to see if time is set correctly on your system if that does not work.

It’s funny, it tried the ‘or’ for the last condition but it still not working… :smile: :persevere:

Then check your time on your system. It’s most likely wrong

Gees…!! :scream: I never tough to check the system time… I’ll do that right now… :roll_eyes:

My system time is up to date…

Tried the easy way…
Tried the complex time condition with an ‘or’…

  condition:
    condition: or
    conditions:
      - condition: time
        after: '21:00:00'
        before: '23:59:59'
      - condition: time
        after: '00:00:01'
        before: '17:30:00'

Nothing works!!! That’s amazing!!! :triumph::crazy_face::dizzy_face::woozy_face:
Jesus, I will stop to play with that damned crap and I will modify the Pithon HA code by myself. That no sens to make a so simple thing so difficult!! :roll_eyes:

What’s your OS time and What is your Home assistant timezone set to?

Also, is the current time inside the specified time of the automation?

This a Hassbian, and my time-zone in raspi-config has been set to America-Montreal…

pi@hassbian:~ $  date "+%H:%M:%S   %d/%m/%y"
16:18:31   16/10/19

and when you use the template editor, outputting your time, it’s correct?

I try to outputting my time into the editor but it fails with an error:

  - service: persistent_notification.create
    data:
      message: ‘Time stamp: {{(now().strftime("%s") | int | timestamp_custom("%H:%M %d-%m-%Y"))}}’ 
      title: test

I think that HA want my head today!!! :crazy_face::dizzy_face:

Do you have a simple solution to get a time stamp?

{{ now() }}

 "message": "{{ now().strftime(\"%H:%M %Y-%m-%d\") }}: is now {{ states.switch.vent_mbr.state }}.",
  "title": "test"

I finally got the time and you know what?

It is all false! 20:42 2019-10-16: is now .

How could it happen??

try using america/toronto or america/new york

1 Like

also, you don’t have to send yourself messages, use the template editor in the dev tools.

1 Like

PETRO Your a king!!!

I fixed my problem! And using the template editor in the dev tools is a good trick! Thanks for all!

I pay you a beer!! :beer::beers:

homeassistant:
  time_zone: America/Montreal

I tough HA was aligning itself to the OS… :roll_eyes: Why doing simple when we can do it complicated…? :smile:

C’est l’une des premières choses à définir.

Donne lui une Maudite! :slight_smile:

Unibroue la Maudite

YES!!! Ou une Exploité… :yum:

C’est quand même bizarre que HA ne se base pas sur l’OS par defaut… :roll_eyes:

J’ai utilisé d’autres logiciels de domotique et ils fonctionnent de la même manière.


Translation:
… strange that HA doesn’t base it (time zone) on the OS
… other home automation software works the same way

1 Like