-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command scheduling, event handling improvements #649
base: master
Are you sure you want to change the base?
Conversation
@kuba2k2 it would be best if each of these point (1..4) could be separate PR's :) |
These features are directly related to each other. I think it doesn't really make sense to split it, after all this PR is only 3 commits. You can review these commits separately and it will (more or less) match these 4 points. |
Hi, any news about this? 🙂 Anything that needs to be fixed before merging? |
My only note is that I think you previously mentioned that you didn't test on ESP32, which is why I'm a bit apprehensive when general dispatch or event functions are refactored. |
Yes, the substitution may not apply to all commands. It should apply to everything that is executed as a text command. Since it is only useful in event actions (because otherwise I do not have an ESP32 platform with a compatible LCD, that's why I can't test it. I can only say that I was very careful to keep the existing behavior of the code, not to impact other users. |
This is the second part of my PR (#631), which was previously reverted to remove changes unrelated to PC port.
This PR adds the following features:
schedule
command, which allows to run another command at a set interval. Any supported command can be executed. It has the following syntax:schedule set <id> <period(ms) <cmd...>
- add/update a scheduled taskid
is a user-chosen integer identifier of the taskperiod
is the interval in millisecondscmd
is the command to run; it can consist of multiple space-separated wordsschedule del <id>
- remove a previously scheduled taskschedule start <id>
- start (enable) a previously scheduled task (enabled by default)schedule stop <id>
- stop (disable) a previously scheduled task, without removing it%var%
tags in commands of objects'"action"
field with a value from the event JSON. For example, this jsonl:will update the label's text whenever the slider emits a
changed
event. Any supported command can be executed, and any value from the JSON event can be used in substitution.NOTE: That feature is disabled by default on non-PC builds, not to impact performance/memory usage on ESP32/Arduino builds. In particular, it requires deserialization of the JSON event prior to publishing, as well as running
std::string::replace()
a few times. It can be enabled usingHASP_USE_EVENT_DATA_SUBST=1
."action"
on all types of controls - previously, only a few controls allowed to run commands on events (script_event_handler()
). Now, all controls callevent_send_object_data()
only, which then callsscript_event_handler()
.If there is an
"action"
tag on the object, the command is executed and MQTT message is not published.An example can be seen above (with the slider).
"action"
tag of an object has an additional property"pub": true
, the action command is ran AND a message is published to MQTT.This property defaults to
false
, which matches the behavior from previous versions.Example:
This slider's events will be published to MQTT, additionally the
changed
event will run a command.I have one more "feature" that was left out of #631, that is setting LVGL max framerate. If you want, I can add it to this PR, otherwise I will probably create another one.