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

Next alarm always showing as January 1, 1970, 12:00 AM #24

Closed sikaiser closed 3 years ago

sikaiser commented 3 years ago

I just set it up the first time, and feel like I did everything correctly according to the readme, but I'm not getting the proper alarm time and date in home assistant.

grafik

My configuration.yaml

# Sensors
sensor:
  - platform: time_date # for Hassalarm
    display_options:
      - 'date_time'

# For Hassalarm
input_datetime:
  next_alarm:
    name: Nächster Wecker
    has_date: true
    has_time: true

My automations.yaml (for webhook). Note, I haven't created any automation to use the alarm yet.

- id: 'hassalarm'
  alias: Webhook for Hassalarm
  trigger:
    platform: webhook
    webhook_id: hassalarm-webhook-2323
  action:
    service: input_datetime.set_datetime
    data_template:
      entity_id: "{{ trigger.json.entity_id }}"
      datetime: "{{ trigger.json.datetime }}"

The app reports "Published Successfully" and correctly shows what the next scheduled alarm is.

Any ideas? Thanks!

Johboh commented 3 years ago

Hey! I think your webhook should be:

- id: 'hassalarm'
  alias: Webhook for Hassalarm
  trigger:
    platform: webhook
    webhook_id: hassalarm-webhook-2323
  action:
    service: input_datetime.set_datetime
    data_template:
      entity_id: "{{ trigger.json.entity_id }}"
      timestamp: "{{ trigger.json.timestamp}}"

E.g. timestamp instead of datetime, as that is what is published from the app (if you check the app logs). Also, what version of Home Assistant are you using?

Johboh commented 3 years ago

Or maybe even:

- id: 'hassalarm'
  alias: Webhook for Hassalarm
  trigger:
    platform: webhook
    webhook_id: hassalarm-webhook-2323
  action:
    service: input_datetime.set_datetime
    data_template:
      entity_id: "{{ trigger.json.entity_id }}"
      timestamp: {{ trigger.json.timestamp}}
Johboh commented 3 years ago

E.g. timestamp: {{ trigger.json.timestamp}} instead of timestamp: "{{ trigger.json.timestamp}}"

sikaiser commented 3 years ago

Thank you! It works with the "", as per your first reply.

And now I got so confused as to why I even did it differently from how you outline it in the readme, but I see you've just already updated it. Awesome!

Johboh commented 3 years ago

@sikaiser Yes I realized that you got it from the Readme and that the Readme was wrong, sorry :)