joggs / home_assistant_ebeco

Integration for Ebeco thermostats
28 stars 14 forks source link

Track power/energy usage, add config flow and more sensors #8

Closed PerfectlyNormal closed 2 years ago

PerfectlyNormal commented 2 years ago

Began as an attempt to track the power/energy usage, but got a bit carried away. I understand completely if this is impossible or unwanted to merge, but thought I might share my attempts. Maybe parts could be adapted. Been running it for few days at home, both in development and my real installation without any issues I could see.

I only have a single Ebeco device installed, so the multi-device support is only theoretical and might not work well at all.

Currently only compatible with HomeAssistant 2021.12.0

This is my first attempt at writing any Python, and anything for HomeAssistant, so there's probably tons of things that could be better. Feel free to suggest and/or edit anything.

robinostlund commented 2 years ago

I just ordered one eb 500, and i am going to use this component, i appreciate existing efforts but think this PR would be really good to merge to. Tracking the energy usage is very interesting for me as i will be building alot of automations around this :)

bhr74 commented 2 years ago

I already have two EB500 wifi and planning for more, and are using those already in HA. I also wish for the energy tracking, would be super nice.

joggs commented 2 years ago

Sorry for the late response guys. I do not have the time to test this now, but I have done the merge, so please test it out and post your results

bhr74 commented 2 years ago

Stupid question maybe, I am just a HA user but want to test it. How do I test it in my HA installation? :-)

joggs commented 2 years ago

I've done a new release now, so you should see it as an update in HACS in a bit. I have not validated this thoroughly before merging this, but it looks like a @PerfectlyNormal release (pun), so let's trust his coding skills :-) Please get back to me if you find any issues

joggs commented 2 years ago

It did not work, so I deleted the release. The whole ebeco entity disappeared. Have not found anything in the logs yet. Maybe the config flow was a breaking change

joggs commented 2 years ago

when manually testing it i get the error Error occurred loading configuration flow for integration ebeco: No module named 'config.custom_components' 3:01:58 PM – (ERROR) config_entries.py - message first occurred at 3:01:26 PM and shows up 2 times

joggs commented 2 years ago

found it. I'll change it to a relative path

joggs commented 2 years ago

new release published to HACS. Please try it out @bhr74

joggs commented 2 years ago

Stupid question maybe, I am just a HA user but want to test it. How do I test it in my HA installation? :-)

If you are using HACS or have used custom components before, you should have a custom_components directory in home assistant. You can just copy the ebeco directory with all its contents to that location and restart home assistant and you should be able to see and add the ebeco integration from the integrations page in home assistant

joggs commented 2 years ago

Have you Added Ebeco from the integrations page and entered info in the setup wizard. To be clear. You add the Ebeco plugin from hacs but when that is done you have to go to home assistants integrations page to add a new integration where you search for Ebeco

lör 29 jan. 2022 kl. 17:15 skrev bhr74 @.***>:

Tried to install it the update now and both termostats became unavailable, also tried to uninstall and a new install but both still unavailable. Something I missed? :-)

— Reply to this email directly, view it on GitHub https://github.com/joggs/home_assistant_ebeco/pull/8#issuecomment-1024940132, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACLJXP3DOYGJTQJ6NZULN3UYQHA3ANCNFSM5J4EHGYQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you modified the open/close state.Message ID: @.***>

--

/Jörgen Bergström

bhr74 commented 2 years ago

Hi, done some testing now and it looks like the EB500 dont want to update changes done from HA to thermostat/APP but changes in app updates HA after some minutes. The power sensor seems to just read the installed effect it dosen reflect if the heat is on or off. The energy sensor works as expected. :-)

bhr74 commented 2 years ago

Have you Added Ebeco from the integrations page and entered info in the setup wizard. To be clear. You add the Ebeco plugin from hacs but when that is done you have to go to home assistants integrations page to add a new integration where you search for Ebeco lör 29 jan. 2022 kl. 17:15 skrev bhr74 @.>: Tried to install it the update now and both termostats became unavailable, also tried to uninstall and a new install but both still unavailable. Something I missed? :-) — Reply to this email directly, view it on GitHub <#8 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACLJXP3DOYGJTQJ6NZULN3UYQHA3ANCNFSM5J4EHGYQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you modified the open/close state.Message ID: @.> -- /Jörgen Bergström

Yes, sorted it minutes after I posted, so I deleted the post. Sorry :-)

joggs commented 2 years ago

Hi, done some testing now and it looks like the EB500 dont want to update changes done from HA to thermostat/APP but changes in app updates HA after some minutes. The power sensor seems to just read the installed effect it dosen reflect if the heat is on or off. The energy sensor works as expected. :-)

Same here regarding changing the temperature from HA. It just gets overwritten by the termostats set value some seconds later and same for me regarding the effect. @PerfectlyNormal could you put some time to try to fix it?

PerfectlyNormal commented 2 years ago

Hm, that's weird. It worked when I was testing it (it always does...)

After that I've left it running on a schedule I set up in the regular Ebeco app, so hadn't noticed that the integration changes gets reset. But I can reproduce the issue, so I'll have a look. I created #10 for the thermostat issue and will try and get some time tomorrow.

The power is just reading the installed effect, and was mostly for information. But since the API also exposes the current state of the relay, I'll change that in #9 to be a bit more dynamic.

Thanks for merging and helping to fix my mistakes @joggs. Guess my coding skills weren't entirely to be trusted :)

joggs commented 2 years ago

That was quick! Great job! 0.6.2 published

terjelindholm commented 2 years ago

Very nice! Works great for me, many thank's.

bhr74 commented 2 years ago

Every thing seems to be working here to, great work . Thanks a lot.

Maybe wrong place to ask but my two EB500 randomly lose the connection to the app, they are connected to the wifi but still no contact with the ebeco app. Happens 4-6 times each day. Anyone else that have this problem. Just to be clear this it nothing to do with this addon :-) I tried support they said this is happening because to a change in the framework from the wificard vendor. But if this the case more customer should have the problem, could it be too many api request?

PerfectlyNormal commented 2 years ago

Every thing seems to be working here to, great work . Thanks a lot.

Maybe wrong place to ask but my two EB500 randomly lose the connection to the app, they are connected to the WiFi but still no contact with the ebeco app. Happens 4-6 times each day. Anyone else that have this problem. Just to be clear this it nothing to do with this addon :-) I tried support they said this is happening because to a change in the framework from the wificard vendor. But if this the case more customer should have the problem, could it be too many api request?

Glad to hear it 👍

@bhr74: I haven't had any WiFi issues that I've noticed. It runs on the 2.4GHz network, so Zigbee-devices around the house can cause conflicts if they aren't set up with correct channels. Those tend to cause issues with the Zigbee-devices, not WiFi in my experience, but who knows.. maybe if combined with a weak WiFi-signal.

If it was happening before you installed the add-on, it shouldn't be too many requests. I don't know how often the EB500 communicates home, but any rate limits should be set way higher than what a normal device or two can manage during normal operation. The add-on has a configuration setting in const.py that tells how often it refreshes the data. If it only started after installing the add-on, that might be worth looking into as well. From the docs:

Du får skicka sammanlagt totalt 10 förfrågningar inom en period på 10 sekunder och totalt 30 förfrågningar inom en period på 60 sekunder.

So max 30 requests per minute. This add-on should do one request per minute per device in regular operation, plus one request each time you change the target temperature or anything like that. If you have an automation that runs, that might cause you to go over. Depending on your network setup, you might be able to see the traffic to ebecoconnect.com and see how much/many requests are sent, and from where.

I don't think we do any good handling of rate limits in the add-on, so if that turns out to be the problem, a solution might be to look into adding some handling and retries with back-off.

bhr74 commented 2 years ago

Hi testing little bit more and its looks like the energy usage sensor will not appear in the energy dashboard, and the value is reset every night, I think this value should be accumulated. Is there something with the integration or can I config the sensor somewhere else?

joggs commented 2 years ago

Hi testing little bit more and its looks like the energy usage sensor will not appear in the energy dashboard, and the value is reset every night, I think this value should be accumulated. Is there something with the integration or can I config the sensor somewhere else?

To my understanding, this is still not natively supported by ebeco, which is the reason it hasn't been added as a feature by me, but did you find a way to handle this @PerfectlyNormal ?

PerfectlyNormal commented 2 years ago

Hi testing little bit more and its looks like the energy usage sensor will not appear in the energy dashboard, and the value is reset every night, I think this value should be accumulated. Is there something with the integration or can I config the sensor somewhere else?

To my understanding, this is still not natively supported by ebeco, which is the reason it hasn't been added as a feature by me, but did you find a way to handle this @PerfectlyNormal ?

It will not be automatically added, but you can add it under Configuration -> Energy -> Individual devices. My sensor is called sensor.badrum_energy_usage, yours will be similar. After a while it gets tracked there. HomeAssistant keeps track of the rest, so you can show the value daily, weekly, monthly and yearly.

If that's not good enough, or you want the accumulated values available elsewhere, you can look into the Utility Meter integration. I haven't personally done that yet, but it's on my list of things to do. That will be local to your installation, nothing this integration can provide, from what I can understand.

I guess the readme should probably be updated with some more instructions/details, since none of this is terribly easy when getting started.

Some extra details: The energy sensor that gets registered is set-up as an energy sensor, with a total increasing amount. Both of which is required to be available in the energy dashboard. The total_increasing is a bit misleading, since those can be reset, but it basically means that the next value will either be larger than the previous , or be reset and go back to zero (monthly or daily is common reset intervals). In the case of this integration, it resets daily.

As a sidenote to the sidenote, the API from Ebeco has some endpoints for fetching energy usage, but from what I can see they're updated once a day, so you can't get the usage for today, only up to yesterday, and there was some other limitations preventing it from being terribly useful. I guess the Ebeco-app uses the same approach we do for showing the usage for today.