#Unable to start timer in conversation

1 messages · Page 1 of 1 (latest)

weak pawn
#

I'm trying to create an automation so my children can ask Nabu if they are allowed to watch TV/play computer games (which they are allowed to do after 8am). If it's before 8am, I'd like it to ask to create a timer, and if so, create it.

I have a script that correctly asks if a timer should be started; however, the timer is never started.

#

This is what I have so far:

alias: Ask if screen time is allowed in morning
description: ""
triggers:
  - command:
      - can i go on the screen
    trigger: conversation
actions:
  - choose:
      - conditions:
          - condition: time
            after: "08:00:00"
        sequence:
          - set_conversation_response: Yes, you can
      - conditions:
          - condition: time
            before: "08:00:00"
        sequence:
          - action: assist_satellite.ask_question
            response_variable: answer
            data:
              question: >-
                No, it's too early. Would you like me to set a {{
                minutes_until_eight }} minute timer?
              preannounce: false
              entity_id: assist_satellite.home_assistant_voice_090f35_assist_satellite
              answers:
                - id: "yes"
                  sentences:
                    - "yes"
                - id: "no"
                  sentences:
                    - "no"
          - if:
              - condition: template
                value_template: "{{ answer is defined and answer.id == 'yes' }}"
            then:
              - action: timer.start
                data:
                  duration: "{{ timer_duration }}"
                target:
                  entity_id: timer.screen_timer
              - set_conversation_response: I've set a timer for {{ minutes_until_eight }} minutes
mode: single
variables:
  now_hour: "{{ now().hour }}"
  now_minute: "{{ now().minute }}"
  minutes_until_eight: >-
    {% set total_now = now_hour * 60 + now_minute %}
    {% set target = 8 * 60 %}
    {% set diff = target - total_now %}
    {{ diff if diff > 0 else 0 }}
  timer_duration: 00:{{ '%02d' % minutes_until_eight }}:00
#

The trace shows that this step is being performed:

#

Unable to start timer in conversation

bitter sinew
#

alternative for minutes_until_eight

{{ (today_at('08:00') - now()).total_seconds() // 60 }}
#

and use that value in setting the timer, like this:

              - action: timer.start
                data:
                  duration:
                    minutes: "{{ minutes_until_eight }}"
                target:
                  entity_id: timer.screen_timer
#

however, it should work like you are doing it as well

weak pawn
bitter sinew
#

does it work if you do this in devtools > actions

action: timer.start
data:
  duration: '00:15:00'
target:
  entity_id: timer.screen_timer
weak pawn
#

Wait a minute. It did work.

#

I can see the timer entity is now running at 15 minutes, but I asked Nabu and it said there are no timers 🤷‍♂️

bitter sinew
#

That will check for timers set on the device

#

you will need to create a 2nd automation which triggers on the timer in HA, and then make the assist sattelite do something

#

e.g. announce that the timer is finished

#

your assist satellite won't do anything on it's own based on that timer, it isn't aware that it exists

weak pawn
#

Not even if I expose it?

bitter sinew
#

it won't act on it automatically if the timer finishes

#

you need to create an automation for that

weak pawn
#

Ahh ok. I'll do that then. I also noticed that after creating the timer, the last message saying the timer has been set doesn't happen either.