Skip to content
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

idle_*.cmd scripts are no longer called #618

Closed
3 tasks done
hb020 opened this issue Jan 21, 2024 · 8 comments
Closed
3 tasks done

idle_*.cmd scripts are no longer called #618

hb020 opened this issue Jan 21, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@hb020
Copy link
Contributor

hb020 commented Jan 21, 2024

Perform all steps below and tick them with [x]

  • Check the related part of the Documentation
  • Update openHASP to the latest version
  • Reproduce the issue and describe all steps

Describe the bug

with today's git HEAD (8d5ae79), the following has arisen:

The idle_*.cmd scripts are no longer called. Very likely due to this commit and #601

Right now, I have
MQTT PUB: idle => long in the logs, but no MSGR: Loading L:/idle_long.cmd

To Reproduce

  • get the latest commit (8d5ae79)
  • create a number of pages (one having number 11 in my example)
  • have the following in idle_long.cmd
json ['page 11']
  • when sending the command "page 11", the page shows.
  • go to another page
  • upon idle_long, the script will not be called and the page will not be called.
  • when reverting to commit 0ebfe7d, it works again.

Expected behavior

upon idle_long, the idle_long.cmd script should be called. (same for and idle_short, and idle_off)

Screenshots or video

none

@hb020 hb020 added the bug Something isn't working label Jan 21, 2024
@hb020 hb020 changed the title idle_* scripts no longer seem to be called idle_* scripts are no longer called Jan 21, 2024
@hb020 hb020 changed the title idle_* scripts are no longer called idle_*.cmd scripts are no longer called Jan 21, 2024
@oklona
Copy link

oklona commented Jan 25, 2024

Hello. To have this work, I just added the following lines to hasp_dispatch.cpp, under line 1359 (the end of function dispatch_idle_state):

if(state == HASP_SLEEP_OFF) { dispatch_run_script(NULL, "L:/idle_off.cmd", state ); } else if(state == HASP_SLEEP_SHORT) { dispatch_run_script(NULL, "L:/idle_short.cmd", state ); } else if(state == HASP_SLEEP_LONG) { dispatch_run_script(NULL, "L:/idle_long.cmd",state ); } else { LOG_WARNING(TAG_MSGR, F("Invalid idle value %d"), state); return; }

I don't know the purpose of the "source" parameter to dispatch_run_script, and it looks like it is not actually used for anything, so I just passed the uint8_t "state".

@yeyeto2788
Copy link

Hey @oklona aren't the filenames incorrect? Based on the docs those are supposed to have - instead of _.

Even if the names are different, did that fully work?

@oklona
Copy link

oklona commented Jan 26, 2024

Yeah, I just copied it from the "dispatch_idle" function below in the source file, which I don't see being called from anywhere. I didn't research much, but it seems to me that "dispatch_idle" was previously used, but was replaced by "dispatch_idle_state". Therefore I assumed I had simply misunderstood the docs. So I did change my file names to use underscore instead of dash. -But apart from that, it worked 100%. Obviously, changing the underscore to dash in the source code would do the same, but during debug I see that underscore is used also for mqtt_on.cmd, mqtt_off.cmd and such. So to me it seems like at some point developers have decided to use underscore.

@yeyeto2788
Copy link

Oh yeah!!! It works 😄. Thanks for that, I guess it would be great to create a PR to the repo.

@hb020
Copy link
Contributor Author

hb020 commented Jan 26, 2024

It could be wise to check with the reason behind the revert commit mentioned above. It moved the script calls to dispatch_idle(), and right now the only places that function gets called is during init phases. It might just be a typo, maybe there is a mix up between dispatch_idle() and dispatch_idle_state(), but anyway, there is reason behind that revert commit. I was hoping for @fvanroie to chime in, he did the commit.

@oklona
Copy link

oklona commented Jan 26, 2024

Agreed. This looks like it has been forgotten somewhere (I cannot find anywhere in the code actually calling dispatch_idle_state() currently). So, since I am very new to this, I only chime in with what could possibly fix this, and leave up to others to decide whether my solution is what they want :-)

@hb020
Copy link
Contributor Author

hb020 commented Jan 27, 2024

Created pull request

@hb020
Copy link
Contributor Author

hb020 commented Jan 28, 2024

PR accepted, tested, closing the issue.

@hb020 hb020 closed this as completed Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants