Johboh / hassalarm

Android app for integration with Hass.io as a sensor for the next scheduled alarm on the device
MIT License
62 stars 6 forks source link

Won't work I think I have an issue with 12h vs 24 hr clock time #16

Closed fourtrax01 closed 4 years ago

fourtrax01 commented 4 years ago

My automations won't trigger even though my next alarm is being updated and my date & time is correct, what I think may be the issue is that my alarm times reports as 8:30 AM and my date & time sensor is reporting on a 24 hour clock without Am/Pm so they never truly match and the automation never fires. Is there a way I can fix this?

Johboh commented 4 years ago

@fourtrax01 Hello! Are you using the legacy sensor or the input_datetime sensor?

fourtrax01 commented 4 years ago

Input_datetime.sensor

Johboh commented 4 years ago

@fourtrax01 What value do you see for the input_datetime when looking at it in hass? And how does your automation look like? Make sure you are comparing the current time using the correct time format.

fourtrax01 commented 4 years ago

This is my value template from my automation, I don't know jinja so I just copied yours. "{{ states('sensor.date_time') == (state_attr('input_datetime.next_alarm', 'timestamp') | int | timestamp_custom('%Y-%m-%d, %H:%M', True)) }}"

fourtrax01 commented 4 years ago

Date & Time 2020-03-26, 05:51

fourtrax01 commented 4 years ago

Screenshot_20200326-055432

Johboh commented 4 years ago

Can you paste these in the template editor to get the values:

date_time: {{ states('sensor.date_time') }}
input timestamp: {{ state_attr('input_datetime.next_alarm', 'timestamp') | int }}
input formatted: {{ state_attr('input_datetime.next_alarm', 'timestamp') | int | timestamp_custom('%Y-%m-%d, %H:%M', True) }}
input formatted 12h: {{ state_attr('input_datetime.next_alarm', 'timestamp') | int | timestamp_custom('%Y-%m-%d, %I:%M %p', True) }}
Johboh commented 4 years ago

And what is your time now? 6:10am or 6:10pm :)? and your alarm is set to 8:30am?

fourtrax01 commented 4 years ago

Screenshot_20200326-062046

fourtrax01 commented 4 years ago

6:21 am alarm set for 8:30 am

fourtrax01 commented 4 years ago

Does it matter that the date is formatted differently as well? My alarm reports March 26, 2020 not 2020-03-26 add the date

Johboh commented 4 years ago

And what if you set an alarm for one minute a head, open the hassalarm app and go in to "Test Connection" to force push a new value, then add these to the template editor:

date_time: {{ states('sensor.date_time') }}
input timestamp: {{ state_attr('input_datetime.next_alarm', 'timestamp') | int }}
input formatted: {{ state_attr('input_datetime.next_alarm', 'timestamp') | int | timestamp_custom('%Y-%m-%d, %H:%M', True) }}
input formatted 12h: {{ state_attr('input_datetime.next_alarm', 'timestamp') | int | timestamp_custom('%Y-%m-%d, %I:%M %p', True) }}
24h/True: {{ states('sensor.date_time') == (state_attr('input_datetime.next_alarm', 'timestamp') | int | timestamp_custom('%Y-%m-%d, %H:%M', True)) }}
12/True: {{ states('sensor.date_time') == (state_attr('input_datetime.next_alarm', 'timestamp') | int | timestamp_custom('%Y-%m-%d, %I:%M', True)) }}
24/False {{ states('sensor.date_time') == (state_attr('input_datetime.next_alarm', 'timestamp') | int | timestamp_custom('%Y-%m-%d, %H:%M', False)) }}
12/False {{ states('sensor.date_time') == (state_attr('input_datetime.next_alarm', 'timestamp') | int | timestamp_custom('%Y-%m-%d, %I:%M', False)) }}
fourtrax01 commented 4 years ago

Screenshot_20200326-064038

Johboh commented 4 years ago

Well you have to wait until 06:42 before your do the evaluation :)

fourtrax01 commented 4 years ago

My alarm went off but the automation didn't trigger

fourtrax01 commented 4 years ago

Is the value template for my automation wrong?

Johboh commented 4 years ago

I want you to evaluate the expressions I posted above in the template editor during the same minute that your alarm is set to trigger, and see if any of the four expressions evaluates to True.

fourtrax01 commented 4 years ago

Then I will have to do it on my computer a little later I can't copy and paste fast enough from my phone to get it all done in a minute. I'll try it out when I actually get up. Thanks I'll let you know

fourtrax01 commented 4 years ago

Screenshot_20200326-065255

Johboh commented 4 years ago

Still the time is not aligned :). 06:51 vs 06:52

fourtrax01 commented 4 years ago

IMAG1309

fourtrax01 commented 4 years ago

Still false

Johboh commented 4 years ago

The problem now is because the alarm is set for tomorrow and not for today 😊. If you look at the date.

fourtrax01 commented 4 years ago

IMAG1310

fourtrax01 commented 4 years ago

The very second the alarm goes off home assistant changes the next scheduled alarm date for the next day, why? Those were one time alarms not recurring ones.

Johboh commented 4 years ago

Make sure you set an alarm which is not a repeated alarm.

fourtrax01 commented 4 years ago

It was not a repeated alarm

fourtrax01 commented 4 years ago

I turned off all other alarms set on my phone and turned battery optimization on for hassalarm app and finally got in to read true. IMAG1316