GithubHelp home page GithubHelp logo

tonsmets / homeassistant-afvalwijzer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xirixiz/homeassistant-afvalwijzer

0.0 1.0 0.0 525 KB

Provides sensors for the Dutch waste collector mijnafvalwijzer.nl and/or afvalstoffendienstkalender.nl

Python 100.00%

homeassistant-afvalwijzer's Introduction

Afvalwijzer

BuyMeCoffee custom_updater hacs_badge hacs_badge made-with-python Open Source Love png1

Component to integrate with afvalwijzer and afvalstoffendienstkalender.

This custom component dynamically creates sensor.afvalwijzer_* items. For me personally the items created are gft, restafval, papier, pmd and kerstbomen. Look in the states overview in the developer tools in Home Assistant what the sensor names for your region are and modify where necessary.

Special thanks go out to https://github.com/heyajohnny/afvalinfo for allowing me to copy scraper code!

This component will set up the following platforms.

Platform Description
sensor Show waste pickup dates for mijnafvalwijzer.nl or afvalstoffendienstkalender.nl.

example

The second row sorts the waste items by date using the following lovelace code

  - type: 'custom:auto-entities'
    card:
      type: glance
    filter:
      include:
        - entity_id: sensor.afvalwijzer_gft
        - entity_id: sensor.afvalwijzer_papier
        - entity_id: sensor.afvalwijzer_pmd
        - entity_id: sensor.afvalwijzer_restafval
    sort:
      attribute: days_until_collection_date
      method: attribute
      numeric: true

More information on the reminders (ios in this case):

Installation

  1. Using you tool of choice open the directory (folder) for your HA configuration (where you find configuration.yaml).
  2. If you do not have a custom_components directory (folder) there, you need to create it.
  3. In the custom_components directory (folder) create a new folder called afvalwijzer.
  4. Download all the files from the custom_components/afvalwijzer/ directory (folder) in this repository.
  5. Place the files you downloaded in the new directory (folder) you created.
  6. Look at the Example Configuration section for further configuration.

Using your HA configuration directory (folder) as a starting point you should now also have this:

custom_components/afvalwijzer/__init__.py
custom_components/afvalwijzer/manifest.json
custom_components/afvalwijzer/sensor.py
CUSTOM COMPONENT USAGE

https://github.com/home-assistant/example-custom-config/tree/master/custom_components/example_sensor

LOGLEVEL

In order to extend the log level, modify the following (configuration.yaml probably)

logger:
  default: info
  logs:
    custom_components.afvalwijzer: debug

EXAMPLE CONFIGURATION (MY CONFIG)

Here's an example of my own Home Asisstant config: https://github.com/xirixiz/home-assistant

SENSOR - CONFIGURATION.YAML - SCRAPER (DEFAULT)
  sensor:
    - platform: afvalwijzer
      provider: mijnafvalwijzer        # (required, default = mijnafvalwijzer) either choose mijnafvalwijzer or afvalstoffendienstkalender
      postal_code: 1111AA              # (required, default = '')
      street_number:  11               # (required, default = '')
      suffix: A                        # (optional, default = '')
      include_date_today: false        # (optional, default = false) to take or not to take Today into account in the next pickup.
      default_label: Geen              # (optional, default = Geen) label if no date found
SENSOR - CONFIGURATION.YAML - API (KEY REQUIRED BUT CANNOT BE OBTAINED!!!)
  sensor:
    - platform: afvalwijzer
      provider: mijnafvalwijzer        # (required, default = mijnafvalwijzer) either choose mijnafvalwijzer or afvalstoffendienstkalender
      api_token: None                  # (required, default = '') KEY REQUIRED BUT CANNOT BE OBTAINED!!!
      postal_code: 1111AA              # (required, default = '')
      street_number:  11               # (required, default = '')
      suffix: A                        # (optional, default = '')
      include_date_today: false        # (optional, default = false) to take or not to take Today into account in the next pickup.
      default_label: Geen              # (optional, default = Geen) label if no date found
INPUT BOOLEAN (FOR AUTOMATION)
input_boolean:
  waste_moved:
    name: Waste has been moved
    initial: 'off'
    icon: mdi:delete-empty
  waste_reminder:
    name: Waste reminder enabled
    initial: 'on'
AUTOMATION
automation:
  - alias: Reset waste notification
    trigger:
      platform: state
      entity_id: input_boolean.waste_moved
      to: 'on'
      for:
        hours: 12
    action:
      - service: input_boolean.turn_off
        entity_id: input_boolean.waste_moved
      - service: input_boolean.turn_on
        entity_id: input_boolean.waste_reminder

  - alias: Mark waste as moved from notification
    trigger:
      platform: event
      event_type: ios.notification_action_fired
      event_data:
        actionName: MARK_WASTE_MOVED
    action:
      - service: input_boolean.turn_on
        entity_id: input_boolean.waste_moved

  - alias: Waste has not been moved
    trigger:
      platform: time_pattern
      minutes: '/60'
      seconds: 00
    condition:
      condition: and
      conditions:
        - condition: state
          entity_id: input_boolean.waste_moved
          state: 'off'
        - condition: state
          entity_id: input_boolean.waste_reminder
          state: 'on'
        - condition: time
          after: '18:00:00'
          before: '23:00:00'
        - condition: template
          value_template: "{{ states('sensor.afvalwijzer_tomorrow') != 'Geen' }}"
    action:
      - service: notify.family
        data:
          title: "Afval"
          message: 'Het is vandaag - {{ now().strftime("%d-%m-%Y") }}. Afvaltype(n): {{ states.sensor.afvalwijzer_tomorrow.state }} wordt opgehaald op: {{ (as_timestamp(now()) + (24*3600)) | timestamp_custom("%d-%m-%Y", True) }}!'
          data:
            push:
              badge: 0
              category: 'afval'

homeassistant-afvalwijzer's People

Contributors

dynasticorpheus avatar github-actions[bot] avatar ktibow avatar marijngiesen avatar p-verbrugge avatar r3mcos3 avatar reharmsen avatar rgruyters avatar thegabeman avatar tonsmets avatar xirixiz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.