Hi All, below you see a automation that work great. But what I want is instead of all sensors want to add a
group.toogoodtogo
Each sensor have state that show amount and attributes:
price: 4.99
stock_available: false
url: http://share.toogoodtogo.com/item/71544
pickup_start: Unknown
pickup_start_human: Unknown
pickup_end: Unknown
pickup_end_human: Unknown
picture: https://images.tgtg.ninja/store/1129390a-5c0f-4933-a574-3a9b8026aaf0.png
unit_of_measurement: portions
friendly_name: Deauvuille Atrium
How can I modify this automation so it will work when I remove all sensors and add the group.toogoodtogo into the trigger? The code below I got from a forum so its not mine… ( I wish )
- id: "notify_me_when_toogoodtogo"
alias: "Notification - TooGoodToGo"
trigger:
- platform: state
entity_id:
- sensor.toogoodtogo_broodhuys_meijer_magic_box
- sensor.toogoodtogo_albert_heijn_amsterdamseweg_amstelveen_magic_box
- sensor.toogoodtogo_albert_heijn_to_go_amsterdam_wtc_magic_box
- sensor.toogoodtogo_boulangerie_noe_gustav_mahlerlaan_amsterdam
- sensor.toogoodtogo_de_drie_graefjes_stadionplein_amsterdam
- sensor.toogoodtogo_hema_gelderlandplein
- sensor.toogoodtogo_lidl_amsterdamseweg_188_groente_fruit_box
- sensor.toogoodtogo_lidl_bankrashof_groente_fruit_box
- sensor.toogoodtogo_starbucks_gustav_mahler_amsterdam
- sensor.toogoodtogo_sushi_time_wtc_amsterdam_magic_box
- sensor.toogoodtogo_the_roastary_magic_box
- sensor.toogoodtogo_poke_perfect_zuidas_magic_box
- sensor.toogoodtogo_juicebrothers_gustav_mahlerlaan_magic_box
- sensor.toogoodtogo_le_pain_quotidien_gelderlandplein_magic_box
- sensor.toogoodtogo_stadsbakker_jongejans_gelderlandplein_magic_box
- sensor.toogoodtogo_brood_en_banketbakkerij_hulleman_buitenveldertselaan_amsterdam
- sensor.toogoodtogo_jumbo_velu_kastelenstraat_amsterdam
- sensor.toogoodtogo_instock_producent_abn_amro_circl
from: false
to: true
attribute: stock_available
mode: queued
variables:
stock: "{{ states(trigger.to_state.entity_id) }}"
name: "{{ state_attr(trigger.to_state.entity_id, 'friendly_name') }}"
picture: "{{ state_attr(trigger.to_state.entity_id, 'picture') }}"
url: "{{ state_attr(trigger.to_state.entity_id, 'url') }}"
action:
- service: script.mobile_notify_no_actionable
data:
title: "TooGoodToGo: {{ name }}"
thread_id: "toogoodtogo"
message: >
{% set entityID = trigger.to_state.entity_id %}
{% set names = state_attr(entityID,'friendly_name').split('-') %}
{% set namesLength = names | length %}
{% if namesLength > 2 %}
{% set outName = names[1] + '-' + names[2] %}
{% else %}
{% set outName = names[1] %}
{% endif %}
{{ name }}: {{ states(entityID) }} x{{ outName }} €{{ state_attr(entityID,'price') }}
img: "{{ picture }}"
buttontitle: "Open TooGoodToGo App"
uri: URI
url: "{{ url }}"
soundname: default
critical: 0
volume: 0
Greetings,
Peter