Custom Countdown Component

Looks ok to me.

Thanks a lot, works as it should :slight_smile:

1 Like

Thank you very much for sharing and all the comments to make a better countdown component. Work really great. ^^

I had set this up in a previous installation of hass.io and it worked great. I’m working on fresh install and can’t seem to get to be recognized. I created the custom_components folder and copied the same exact files I used before. But now I’m getting an “Integration date_countdown not found when trying to verify its sensor platform.” error message. I’ve updated the folder structure so it’s now ‘\config\custom_component\countdown\sensor.py’ but still get the same error message. I do have an empty ‘init.py’ & ‘mainifest.json’

Ryan,

I just re-added the component to my config and ran into the same issue. After messing around a bit, this seems to be what fixed it: Stopping HASS, touching __init__.py, and deleting the __pycache__ folder (if present),

Here’s what I have after it’s running again:

ls /homeassistant/custom_components/date_countdown
__init__.py  __pycache__  sensor.py
- platform: date_countdown
  name: Wedding Countdown
  date: "20-05-2020 18:00"

Does this still work?

My sensor just returns unavailable. How to debug?

Hey there, there might have been some changes. I edited my original post but you can also find the code at https://github.com/aneisch/home-assistant-config/tree/master/custom_components/date_countdown. I just re-enabled this in my sensors.yaml and it works as expected.

- platform: date_countdown
  name: Test Countdown
  # day-month-year hour:minute
  date: "20-05-2020 18:00"

Thanks for quick response.

Does the script need to be called sensor.py or date_countdown.py ?

What owner and permissions does init.py need ?

Can the sensors.yaml config be stored just in normal configuration.yaml ?

If not, where does sensors.yaml need to be stored in /home-assistant-config/custom_components/date_countdown/sensors.yaml

Or just in /home-assistant-config/sensors.yaml ?

Any other steps to debug welcomed.

It needs to be called sensor.py, I’m not sure about permissions of init, mine are 664, owned by my user. Yes, you can have your sensor config in configuration.yaml in your sensors section, no requirement to split out the files.

/home-assistant-config/sensors.yaml ?
Yes.

Anyone knows how to create a countdown timer from a dynamic duration. I have 3 buttons each has a diff time (30mins, 45mins, and 60mins). So my timer duration depends which one was clicked but when I do the following code Hassio gives me an error:

sensor:
  - platform: template
    sensors:
      irrigation_time:
        value_template: >-
          {% if states('switch.irrig_front_yard') == 'on' %}
            00:{{ states('input_number.irrigation_frontyardduration') | int }}:00
          {% elif states('switch.irrig_cedars') == 'on' %}
            00:{{ states('input_number.irrigation_cedarsduration') | int }}:00
          {% elif states('switch.irrig_front_side_yard') == 'on' %}
            00:{{ states('input_number.irrigation_frontsideduration') | int }}:00
          {% elif states('switch.irrig_front_guest_yard') == 'on' %}
            00:{{ states('input_number.irrigation_frontguestduration') | int }}:00
          {% else %}
            00:00:00
          {% endif %}

timer:
  irrigation_counter:
    duration: "{{ states('sensor.irrigation_time') | int }}"

What’s the error?

I changed things but still it doesn’t work:

sensor:
  - platform: template
    sensors:
      irrigation_time:
        value_template: >-
          {% if states('switch.irrig_front_yard') == 'on' %}
            00:{{ states('input_number.irrigation_frontyardduration') | int }}:00
          {% elif states('switch.irrig_cedars') == 'on' %}
            00:{{ states('input_number.irrigation_cedarsduration') | int }}:00
          {% elif states('switch.irrig_front_side_yard') == 'on' %}
            00:{{ states('input_number.irrigation_frontsideduration') | int }}:00
          {% elif states('switch.irrig_front_guest_yard') == 'on' %}
            00:{{ states('input_number.irrigation_frontguestduration') | int }}:00
          {% else %}
            00:00:00
          {% endif %}

timer:
  irrigation_timer:

script:
  irrigation_counter:
  sequence:
    - service: timer.start
      data_template:
        entity_id: timer.irrigation_timer
        duration: '{{ states.sensor.irrigation_time.state | int }}'

Error:
Invalid config for [script]: expected a dictionary for dictionary value @ data[‘script’][‘irrigation_counter’]. Got None expected a dictionary for dictionary value @ data[‘script’][‘sequence’]. Got [OrderedDict([(‘service’, ‘timer.start’), (‘data_template’, OrderedDict([(‘entity_id’, ‘timer.irrigation_timer’), (‘duration’, ‘{{ states.sensor.irrigation_time.state | int }}’)]))])]. (See /config/configuration.yaml, line 390).

Indent sequence: and everything below.

Sorry I ended up fixing it that day, yes it was an indentation error.