Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Button Options for Timer Duration

$
0
0

@GeorgeIoak wrote:

My goal is to have an option to continue running a fan for 3 different durations. To easily select the times I’d like to display the choices as buttons. These should be like an input_select in that it makes sense to only have 1 option (or none) selected at a time. I believe I’ve got the UI somewhat how I want it using this for the card:

- type: "custom:hui-entities-card"
        title: Garage AFS
        show_header_toggle: false
        entities:
          - entity: switch.garage_fan
          - entity: fan.garage_afs
            type: custom:fan-control-entity-row
            name: Garage Air Filter
            customTheme: false
          - type: "custom:button-entity-row"
            buttons:
              - entity: input_boolean.timer_30min
                name: 30
                service: script.afs_30
                #service_data:
                #  entity_id: 
                style:
                - flex-direction: column
                icon_style:
                  - padding-right: 0 !important
                  - '--iron-icon-height': 2.5em
                  - '--iron-icon-width': 2.5em
                state_styles:
                  "off":
                    font-weight: normal
                  "on":
                    color: green
                    font-weight: bold
              - entity: input_boolean.timer_60min
                name: 60
                service: script.garage_afs_off
                state_styles:
                  "off":
                    font-weight: normal
                  "on":
                    color: green
                    font-weight: bold
              - entity: input_boolean.timer_90min
                name: 90
                service: script.garage_afs_off

I just have booleans for the buttons defined as:

timer_30min:
  name: 30min
  icon: mdi:timer
  initial: off

timer_60min:
  name: 60min
  icon: mdi:timer
  initial: off

timer_90min:
  name: 90min
  icon: mdi:timer
  initial: off

and then the script is currently this:

afs_30:
  alias: AFS OFF After 30min
  sequence:
  - entity_id: input_boolean.timer_30min
    service: input_boolean.toggle
  - entity_id: input_boolean.timer_60min
    service: input_boolean.turn_off
  - entity_id: input_boolean.timer_90min
    service: input_boolean.turn_off
  - condition: state
    entity_id: input_boolean.timer_30min
    state: 'on'
  - delay: 00:30:00
  - entity_id: script.garage_afs_off
    service: homeassistant.turn_on
  - entity_id: input_boolean.timer_30min
    service: input_boolean.turn_off

I’m still in the testing phase as well as trying to determine if I’m even going about this the best way seems it seems rather convoluted to me. I do get this error thrown when I try the “30 minute timer” so with this code it’s not working properly yet.

AttributeError: 'NoneType' object has no attribute 'is_on'
2020-02-10 17:27:30 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140600466809040] 'NoneType' object has no attribute 'is_on'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1226, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1251, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 202, in service_handler
    if script.is_on:

I initially tried using a timer and passing the duration based on which button was pressed but I couldn’t get that to work but I’m a little stuck on how to clean up this mess and get it to work.

Posts: 4

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>