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

Would it be possible to add the health status? updateHealth() #2

Open
azagramac opened this issue Apr 15, 2024 · 1 comment
Open

Would it be possible to add the health status? updateHealth() #2

azagramac opened this issue Apr 15, 2024 · 1 comment
Assignees
Labels
TO DO This issue/suggestion will be fixed/added

Comments

@azagramac
Copy link

Good, I do not know if you have raised the idea of adding the health status, there is documentation available and does not look complicated, I took the trouble to take a snippet of code from the script.js file and add code as an example.

        function updateAllBatteryInfo() {
            updateChargeInfo();
            updateLevelInfo();
            updateHealth();
            updateChargingInfo();
            updateDischargingInfo();
            temperature.innerText = battery.temperature + '°'
            temperatureUpdateInterval = setInterval(() => { temperature.innerText = battery.temperature + '°' }, 60000 * 5);
        }
        updateAllBatteryInfo();
        //events
        battery.addEventListener('chargingchange', updateChargeInfo);

        battery.addEventListener('levelchange', updateLevelInfo);
        // new function
        battery.addEventListener('healthchange', updateHealth);

        battery.addEventListener('chargingtimechange', updateChargingInfo);

        battery.addEventListener('dischargingtimechange', updateDischargingInfo);

        function updateChargeInfo() {
            a = document.querySelector('#container');
            battery.charging ? (a.classList.add('charging'), setInterval(() => { temperature.innerText = battery.temperature + '°' }, 60000 * 2)) : (a.classList.remove('charging'), alarm.pause(), setInterval(() => { temperature.innerText = battery.temperature + '°' }, 60000 * 5));
        }

        function updateHealth() {
            h = document.querySelector('#health');
            // add function, more info: https://developer.kaiostech.com/docs/api/web-apis/batterymanager/health
        }

Regards.

@W4IT-Dev
Copy link
Owner

Hello there!

Thank you for the idea.
I have indeed already thought about it and I will add it to the version 1.5.0.
There is still another version in the QA process and after that, I will soon start to develop the new version.
I won't display the health directly, but will give an alert if your battery is overheating or if it's too cold.

I would greatly appreciate your thoughts on that way of implementing it.

Best Regards

@W4IT-Dev W4IT-Dev self-assigned this Apr 16, 2024
@W4IT-Dev W4IT-Dev added the TO DO This issue/suggestion will be fixed/added label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TO DO This issue/suggestion will be fixed/added
Projects
None yet
Development

No branches or pull requests

2 participants