Closed Sarnog closed 1 year ago
I use two custom cards to see which TGTG boxes are available, the auto-enties card and the multiple-entity row.
type: custom:auto-entities
card:
type: entities
title: Beschikbaar
filter:
template: |-
{% for state in states.sensor -%}
{%- if state.state>= '1' and 'sensor.tgtg_' in state.entity_id %}
{%- if state_attr(state.entity_id, 'pickup_start') is not none -%}
{{
{
'entity': state.entity_id,
'name': state.attributes.friendly_name[5:],
'type': "custom:multiple-entity-row",
'unit': false,
'secondary_info': 'Ophalen op ' + state.attributes.pickup_start[8:10] + "-" + state.attributes.pickup_start[5:7] + ' tussen '+ state.attributes.pickup_start[11:16] + ' en ' + state.attributes.pickup_end[11:16] + ', € '+ state.attributes.item_price[:-3],
'tap_action': {
'action': 'url',
'url_path': state.attributes.item_url}
}
}},
{%- endif -%}
{%- endif -%}
{%- endfor %}
Thanks for the card! Altho they remain empty, even when i receive a notification when there is something available. What i'm i doing wrong?
I don't know... indentation is very important with this card. I had some trouble with it. If you copy and paste the code in the template editor, does that work? By the way, there is an error with the pickup time in the card, it's an hour to early in the card
I don't know... indentation is very important with this card. I had some trouble with it. If you copy and paste the code in the template editor, does that work? By the way, there is an error with the pickup time in the card, it's an hour to early in the card
On the template editor i get this error:
TypeError: '>=' not supported between instances of 'float' and 'str'
That's strange. I copied the code above in my template editor, no problem. Did you copy all the code? And if you delete the part with >=?
That's strange. I copied the code above in my template editor, no problem. Did you copy all the code? And if you delete the part with >=?
This is what i put in the editor:
{% for state in states.sensor -%}
{%- if state.state>= '1' and 'sensor.tgtg_' in state.entity_id %}
{%- if state_attr(state.entity_id, 'pickup_start') is not none -%}
{{
{
'entity': state.entity_id,
'name': state.attributes.friendly_name[5:],
'type': "custom:multiple-entity-row",
'unit': false,
'secondary_info': 'Ophalen op ' + state.attributes.pickup_start[8:10] + "-" + state.attributes.pickup_start[5:7] + ' tussen '+ state.attributes.pickup_start[11:16] + ' en ' + state.attributes.pickup_end[11:16] + ', € '+ state.attributes.item_price[:-3],
'tap_action': {
'action': 'url',
'url_path': state.attributes.item_url}
}
}},
{%- endif -%}
{%- endif -%}
{%- endfor %}
Ssems like this code is working:
type: custom:auto-entities
card:
type: entities
title: Beschikbare boxen TGTG
filter:
template: |-
{% for state in states.sensor -%}
{%- if state.state|float(default=0) >= 1 and 'sensor.tgtg_' in state.entity_id %}
{%- if state_attr(state.entity_id, 'pickup_start') is not none -%}
{{
{
'entity': state.entity_id,
'name': state.attributes.friendly_name[5:],
'type': "custom:multiple-entity-row",
'unit': false,
'secondary_info': 'Ophalen op ' + state.attributes.pickup_start[8:10] + "-" + state.attributes.pickup_start[5:7] + ' tussen '+ state.attributes.pickup_start[11:16] + ' en ' + state.attributes.pickup_end[11:16] + ', € '+ state.attributes.item_price[:-3],
'tap_action': {
'action': 'url',
'url_path': state.attributes.item_url}
}
}},
{%- endif -%}
{%- endif -%}
{%- endfor %}
Thanks, added it to the readme.
This is amazing. I never used auto_entities, but would it be possible to add a filter of entities for pickup today or pickup tomorrow?
I use two custom cards to see which TGTG boxes are available, the auto-enties card and the multiple-entity row.
type: custom:auto-entities card: type: entities title: Beschikbaar filter: template: |- {% for state in states.sensor -%} {%- if state.state>= '1' and 'sensor.tgtg_' in state.entity_id %} {%- if state_attr(state.entity_id, 'pickup_start') is not none -%} {{ { 'entity': state.entity_id, 'name': state.attributes.friendly_name[5:], 'type': "custom:multiple-entity-row", 'unit': false, 'secondary_info': 'Ophalen op ' + state.attributes.pickup_start[8:10] + "-" + state.attributes.pickup_start[5:7] + ' tussen '+ state.attributes.pickup_start[11:16] + ' en ' + state.attributes.pickup_end[11:16] + ', € '+ state.attributes.item_price[:-3], 'tap_action': { 'action': 'url', 'url_path': state.attributes.item_url} } }}, {%- endif -%} {%- endif -%} {%- endfor %}
Thanks. Works great. I’m just wondering how to adjust the time. The attribute shows e.g. pickup_start 15:10, but it is actually 17:10. So 2 hours difference. I live in the Netherlands. Can I adjust it in your card example or do I have to do this in another way. Hope you can share how you are handling the time zone.
where do i paste the code?
You could use this line for displaying the pickup times in your local timezone:
'secondary_info': as_timestamp(as_datetime(state.attributes.pickup_start).astimezone()) | timestamp_custom('%a %d/%m') | lower + ' between ' + as_timestamp(as_datetime(state.attributes.pickup_start).astimezone()) | timestamp_custom('%H:%M') + ' and ' + as_timestamp(as_datetime(state.attributes.pickup_end).astimezone()) | timestamp_custom('%H:%M') + ', € ' + state.attributes.item_price[:-3],
Checklist
Is your feature request related to a problem? Please describe.
Hello,
Is there any way to create a markdown card or something like that, that fills automaticly with all the tgtg sensors, and displays only the sensors, that are active. Ofcourse i would love to see this with the attributes showen as well.
Example:
Describe the solution you'd like
Maybe anybody can do something with auto-entities mod and/or markdown card? I tried, but can't figure it out. I'm lacking skills for this.
Describe alternatives you've considered
Not have it showen on my dashboard... :-/
Additional context