Comments (4)
Ah - I didn't think of that, since I overloaded @time_trigger
with no arguments to handle the startup/reload case.
Here's a quick fix. Just have a 2nd function that handles the startup/reload trigger, and call the same function:
@time_trigger
def set_daytime_on_startup():
set_daytime()
You could add a function argument so your function can tell the difference between startup and a time trigger.
I'll plan on adding a "startup" time-spec option to @time_trigger
so it can be used alongside the other time specifications.
Note also that you could collapse your four hour-based arguments into one using cron
:
@time_trigger("cron(0 8,10,18,21 * * *)", "once(sunrise)", "once(sunset)")
BTW, I just released a new version that supports Jupyter, making it much easier to write, debug and test code and logic. It's way easier to use that than saving / reload.
Cheers.
from pyscript.
Thanks for the quick reply. I am already knee-deep in jupyter and debugpy debugger looking at the inner workings of your component.
I was thinking of using a second function with a seperate trigger, but wanted to be sure, there was no easier way.
By the way, similar problem quickly arises, when different event type/expression combinations are needed.
You're right regarding the cron notation but I prefer having each definition separate.
To make processing of multiple time_triggers / trigger types easier in the called function, I propose for @time_trigger
:
trigger_type
is always set totime
- add keyword argument
time_spec
set to thedatetime
of the definition responsible and maybeNone
for startup/reload
from pyscript.
Good suggestions. I'll add them to my todo list.
from pyscript.
"startup" is now a valid @time_trigger
argument with commit 59a5461. I ended up using trigger_time
as the datetime
for the trigger time that caused the trigger.
from pyscript.
Related Issues (20)
- [Feature Request] Error/warning when function name is duplicated in code
- Even with supports_response, service is not returning anything HOT 2
- not implemented ast ast_generatorexp HOT 1
- can not import library after reboot of HA
- Expose home assistant jinja template functions HOT 1
- Croniter version conflict HOT 1
- "MQTT entity name starts with the device name in your config"
- Feature Request: Make apps configurable from Home assistant UI
- Feature Request: exclude from recorder
- attribute changes not detected
- "async with" statement fails without target variable assignment
- Newbie help running Python script under pyscript as a service HOT 2
- Translated state HOT 1
- Template evaluation HOT 2
- Exception in <file.pv_excess_control.on_time> line 246 HOT 2
- Issues using yaml module in pyscript HOT 2
- Python 3.11 support removed from Home Assistant HOT 4
- помогите с IMPORT в home asistant HOT 1
- PyRight LSP HOT 9
- Sending group notifications raise errors
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyscript.