Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templates not working with current attribute lay-out #11

Open
JanesCasa opened this issue Dec 2, 2020 · 2 comments
Open

Templates not working with current attribute lay-out #11

JanesCasa opened this issue Dec 2, 2020 · 2 comments

Comments

@JanesCasa
Copy link

Hello,

I am not able to use the 'window_start' time within the 'picnic_delivery' sensor to trigger automations with the current format of the attributes. It looks like the window_start attribute is an attribute itself from 'delivery:'. Can't get the window_start as an output within a template this way. Maybe I miss something inportant? Otherwise, is it posible to reformat the attributes from the picnic_delivery sensor so that they are without any extra spacing?

The attributes from the 'sensor.picnic_delivery' looks as follows within my HA:
attribution: Information provided by Picnic.app
delivery:
creation_time: '2020-12-01T12:25:16.711+01:00'
delivery_id: eaptye6mqe
slot_id: 5fb312887e212112540051d5
hub_id: (SECRET)
fc_id: FC1
window_start: '2020-12-02T20:19:00+01:00'
window_end: '2020-12-02T20:39:00+01:00'
cut_off_time: '2020-12-01T22:00:00+01:00'
is_available: false
selected: false
reserved: false
minimum_order_value: 3500
unavailability_reason: CLOSED
friendly_name: picnic_delivery
icon: 'mdi:truck-delivery'

Thanks in edvance for helping me out or solving this issue. 😊

@JanesCasa
Copy link
Author

Schermafbeelding 2020-12-02 om 13 46 52

Just to be sure, a screenshot of the current state and attributes of the 'sensor.picnic_delivery'.

@schreg
Copy link

schreg commented Dec 26, 2020

I solved that with this template:

  • platform: template
    sensors:
    picnic_liefer_zeit_anfang:
    friendly_name: "Picnic Lieferzeitfenster Start"
    icon_template: mdi:clock-outline
    value_template: '{{as_timestamp(states.sensor.picnic_delivery.attributes["delivery"]["window_start"]) | timestamp_custom ("%d-%m-%Y %H:%M") }}'

I use this sensor to get informed one hour before the time window closes to order goods:

  • platform: template
    sensors:
    picnic_order_last_chance:
    friendly_name: "Picnic letzte Chance "
    value_template: '{{as_timestamp(states.sensor.picnic_delivery.attributes["delivery"]["cut_off_time"]) | timestamp_custom ("%d-%m-%Y %H:%M") }}'

This is my automation:

  • id: 'XXXXXXXX'
    alias: Picnic letzte Chance
    description: Das Zeitfenster zum Befüllen des Warenkorbs endet in 1 Stunde
    trigger:
    • platform: template
      value_template: "'{{ (((states.sensor.picnic_order_last_chance.state)| int) -
      \ as_timestamp(states.sensor.date.state\n + '' '' + states.sensor.time.state)
      \ |int ) - 3690 < 0 }}'"
      condition: []
      action:
    • service: input_boolean.toggle
      data: {}
      entity_id: input_boolean.shopping_list_message
    • service: notify.ha_nachricht
      data:
      message: XXXXXXXX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants