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

fix: sleep duration again & send sleep duration to mqtt #53

Merged
merged 3 commits into from
Sep 12, 2024

Conversation

pimlie
Copy link
Contributor

@pimlie pimlie commented Sep 2, 2024

Ok, third time is the charm 😞

This is starting to get embarrassing, but in my defense I didn't realize before I had configured my TIME_TO_SLEEP_MIN to 5 minutes and also configured the variable sleep duration's during the day to be 5 minutes. So while I was working on this during the day, it seemed it was using the correct sleep duration even though it was just using the default sleep :(

As a similar issue could exists for other people when your configured time slots are f.e. not continuous, I realized it would be helpful to store the actual sleep duration as diagnostic in mqtt/hass so you can check it's correct even when you are normally sleeping.

I'll make this a draft pr for now and check tomorrow that it's actually fixed now...

fyi @felixh10r

@pimlie
Copy link
Contributor Author

pimlie commented Sep 2, 2024

Also made mqtt expire_after configurable, I have set my TIME_TO_SLEEP_MIN to 1 min now and noticed that all entries in hass became unavailable before the homeplate woke up after 5 minutes.

@pimlie pimlie marked this pull request as ready for review September 3, 2024 07:54
@pimlie
Copy link
Contributor Author

pimlie commented Sep 3, 2024

Can confirm it is working correctly now:
image

@lanrat
Copy link
Owner

lanrat commented Sep 3, 2024

Is there a test case that can be added to ensure future updates don't break this functionality? Since I don't use this functionality myself, it would help guarantee it keeps working into the future.

@pimlie
Copy link
Contributor Author

pimlie commented Sep 3, 2024

Unfortuntely not, at least not easily. The main issue with this not working was that I added the #define CONFIG_CPP to the cpp file and not to the header file, but the cpp file isn't even loaded yet when the preprocessor that handles the #define's runs so CONFIG_CPP was just never defined in activity.cpp

The only way you could test for that is by actually building homeplate with a valid config and then run a test using https://github.com/espressif/qemu, but that seems quite a bit of work which I don't think is worth it. By publishing the sleep status to home assistant we at least have the next best thing, i.e. that we can easily monitor if it still works correctly ;)

@lanrat lanrat merged commit 3e231e2 into lanrat:main Sep 12, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants