You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As part of my View Assist project I am trying to implement some disposable timers that can be called using Assist voice assistant. I am doing this to prevent from having a lot of timer helpers for each satellite device.
I think I will be able to do this with Pyscript as the simple proof of concept I have put together works:
import asyncio
@service
def viewassist_timer(action=None, duration=None, id=None):
if action == "starttimer" and duration is not None:
time_remaining = duration
while time_remaining >0:
asyncio.sleep(1)
time_remaining -=1
event.fire('viewassist_timer_expired', param1=action, pararm2=id, param3=duration)
This simple script works in that the user can say "Set an egg timer for 120 seconds" and a service call will be made to this function that waits for the duration and then returns an event that can then be used to alert the user that the timer has expired.
This works but I'd like to add something in the while loop that would detect if the user wanted to cancel the timer. Can I put an event trigger within that loop? I'm thinking if I had an event that contained the event_type 'viewassist_timer_cancel' along with either the id (for example "egg") or the duration then that could identify the timer to cancel. I am also wanting to have multiple timers running simultaneously and would need a way to separate the running processes.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
As part of my View Assist project I am trying to implement some disposable timers that can be called using Assist voice assistant. I am doing this to prevent from having a lot of timer helpers for each satellite device.
I think I will be able to do this with Pyscript as the simple proof of concept I have put together works:
This simple script works in that the user can say "Set an egg timer for 120 seconds" and a service call will be made to this function that waits for the duration and then returns an event that can then be used to alert the user that the timer has expired.
This works but I'd like to add something in the while loop that would detect if the user wanted to cancel the timer. Can I put an event trigger within that loop? I'm thinking if I had an event that contained the event_type 'viewassist_timer_cancel' along with either the id (for example "egg") or the duration then that could identify the timer to cancel. I am also wanting to have multiple timers running simultaneously and would need a way to separate the running processes.
Anyone have thoughts on how to best do this?
Beta Was this translation helpful? Give feedback.
All reactions