Skip to content

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

Merged
lanrat merged 3 commits intolanrat:mainfrom
pimlie:fix-sleep-duration-for-real
Sep 12, 2024
Merged

fix: sleep duration again & send sleep duration to mqtt#53
lanrat merged 3 commits intolanrat:mainfrom
pimlie:fix-sleep-duration-for-real

Conversation

@pimlie
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

pimlie commented Sep 3, 2024

Can confirm it is working correctly now:
image

@lanrat
Copy link
Copy Markdown
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
Copy Markdown
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
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