bruxy70 / Garbage-Collection

🗑 Custom Home Assistant sensor for scheduling garbage collection (or other regularly re-occurring events - weekly on given days, semi-weekly or monthly)
MIT License
382 stars 90 forks source link

Set date from sensor? #389

Closed Naesstrom closed 2 years ago

Naesstrom commented 2 years ago

Before you submit a new bug report, please check that

Write your question here

I've managed to get a json source from my garbage collection company and made a date sensor for each bin from that via REST. image Karl_1_2 and Karl_2_2 is the ones with the date from the rest sensor and the others is from your component. Can I somehow use the rest sensors to set the date for the component, right now I'm just using the every-n-weeks approach.

bruxy70 commented 2 years ago

Yes, you can use the manual update, and set the date by an automation triggered by the garbage collection loaded event. Check the documentation, and the included blueprints

Naesstrom commented 2 years ago

Ah yes I see, didn't dare to click the "BEWARE, more advanced yaml here" part at first but it worked just great! For future reference if someone else want's to do the same this is my automation

alias: garbage_collection update bin1
description: 'Update collection date for bin 1 from rest sensor'
trigger:
  - platform: event
    event_type: garbage_collection_loaded
    event_data:
      entity_id: sensor.bin_1
action:
  - service: garbage_collection.add_date
    data:
      entity_id: '{{ trigger.event.data.entity_id }}'
      date: '{{ states("sensor.bin_1_rest") }}'
  - service: garbage_collection.update_state
    data:
      entity_id: sensor.bin_1
mode: single

Didn't work at first but that was just me being stupid, need to change the bins config to manual ^^ yes... like the manual says....