crownstone / crownstone-home-assistant

Beta version of the Crownstone integration for Home Assistant
6 stars 3 forks source link

[Feature Request] show energy & power usage #2

Closed jonathanhofman81 closed 3 years ago

jonathanhofman81 commented 4 years ago

Would it be difficult to add support for energy usage and power usage? It is a nice feature and would make nice dashboards in HA. I wouldn't need a real time 'high performance' energy usage. Updates of the energy usage in 15 mins or 1 hour could be sufficient (1 minute intervals would be better). Power usage could be less frequent snapshots also.

BTW I'm using the USB stick

RicArch97 commented 4 years ago

Thanks for your feature request!

Power usage sensor is on the roadmap for the next update! However, I currently don't have time to work on that so I can't give you an exact time/date for when this will be implemented into the integration

mrquincle commented 4 years ago

Hi!

The support for energy and power monitoring is already implemented in the firmware and is communicated through the mesh towards the dongle. The python UART library is also able to receive this. The rate is at around 1 message per minute.

This feature request would then require integration of this function within Home Assistant. We'll discuss internally when it's likely that this function will be there. Now, I'd estimate it would arrive on our planning in around 4,5 sprints (couple of months). In the meantime, feel free to do a pull request. :-)

jonathanhofman81 commented 4 years ago

Hi,

Tnx, the confirmation that it is already part of the mesh communication and the uart library for the dongle motivates indeed to start implementing it myself if time permits. If so, I will certainly create a pull request. Good to know that it is on the roadmap somewhere and will be coming if I'm not able to add it sooner.

BTW: the integration with Home Assistant is quite nice. The setup of new devices works quite well out of the box with very little steps. So well done :-). Of course, there are things to add and improve, but I'm very pleased already.

Op di 27 okt. 2020 om 10:45 schreef Anne van Rossum < notifications@github.com>:

Hi!

The support for energy and power monitoring is already implemented in the firmware and is communicated through the mesh towards the dongle. The python UART library is also able to receive this. The rate is at around 1 message per minute.

This feature request would then require integration of this function within Home Assistant. We'll discuss internally when it's likely that this function will be there. Now, I'd estimate it would arrive on our planning in around 4,5 sprints (couple of months). In the meantime, feel free to do a pull request. :-)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/crownstone/crownstone-home-assistant/issues/2#issuecomment-717117511, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD526QSSEH7VNXXMMG4QJTTSM2JCDANCNFSM4S2MUSDA .

RicArch97 commented 4 years ago

Hey! Thanks for your reply!

I'm the developer of the entire integration so far and I'm glad you like it!

The power usage implementation is something I could add in a day or two, since all of the code is known to me (including all of the code of Home Assistant core). I might look at it this weekend and add support for energy usage updates using the USB dongle. We can look into adding support for periodic polling (~10 minutes interval) of the energy usage for non-usbdongle users later on.

Oh btw, what are the things you think could be improved in the integration? Thanks!

RicArch97 commented 4 years ago

Quick update on the progress:

Next update will be quite large and will include more than just the power usage. dependencies have been updated with new features & bug fixes, and the integration will support updating during runtime, any changes made in the app (updating name, adding/ deleting Crownstones etc) will immediately be processed in HA.

The cloud switch command has been reworked so that every command comes in, even when switching really fast or switching multiple Crownstones, so state updates coming from the app will now also be instantly processed in HA, for both cloud and usb.

As for the power usage measurements, this will only be possible using the Crownstone USB. We are looking at making it as accurate as possible. Without the USB the entities state will be "unavailable".

I'm planning on including the updated uart lib with the new protocol with this update. So release will be done after that releases.

jonathanhofman81 commented 4 years ago

Looks great! Also the update of states will be very welcome. Would that mean that also changed state due to switchcraft will be reflected in HA?

Looking forward to the release and will be happy to try it out.

hillstub commented 4 years ago

Another very happy user. Good to hear you guys are working on this and looking forward to implement tracking of power usage in my home assistant set-up as well!

ddcbe commented 4 years ago

Same here! Since this integration the crownstones really show their potential!

RicArch97 commented 4 years ago

Looks great! Also the update of states will be very welcome. Would that mean that also changed state due to switchcraft will be reflected in HA?

Looking forward to the release and will be happy to try it out.

The state change due to Switchcraft will be reflected in HA, but only using the Crownstone USB dongle. When state changes are coming from the app, they are reflected in HA by both Cloud and USB in the new version.

ddcbe commented 4 years ago

Hi, thanks for the new release! I tried it and it works but not for all crownstones: In my setup I have 5 crownstones ( 4 zeros one cronwstone one). For two of them, the power usage is shown. For the other 3, there is no entity reflecting the power consumption. I already tried by deleting the integration and adding it again but that doesn't make any difference. Any suggestions or additional info which I can provide?

AlexDM0 commented 4 years ago

Hi, just small question before we continue, are all Crownstones updated to the latest firmware?

EDIT: removed email history

RicArch97 commented 4 years ago

Hi, thanks for the new release! I tried it and it works but not for all crownstones: In my setup I have 5 crownstones ( 4 zeros one cronwstone one). For two of them, the power usage is shown. For the other 3, there is no entity reflecting the power consumption. I already tried by deleting the integration and adding it again but that doesn't make any difference. Any suggestions or additional info which I can provide?

Thanks for your feedback!

Do you have any logs with error messages by any chance? You can find them in Configuration -> Logs.

ddcbe commented 4 years ago

Hi,

all cronwstones are running the latest firmware: 5.2.1

This are the entries I could find in the logs: 2020-11-21 21:03:51 ERROR (MainThread) [homeassistant.components.sensor] Platform crownstone does not generate unique IDs. ID 2 already exists - ignoring sensor.living_2 2020-11-21 21:03:51 ERROR (MainThread) [homeassistant.components.sensor] Platform crownstone does not generate unique IDs. ID 3 already exists - ignoring sensor.master_bedroom 2020-11-21 21:03:51 ERROR (MainThread) [homeassistant.components.sensor] Platform crownstone does not generate unique IDs. ID 4 already exists - ignoring sensor.overloop

RicArch97 commented 4 years ago

Hi

In case of entity ID's, home assistant is initially in charge of creating them and providing an entity ID that does not exist yet. It does that by combining the platform and the entity's name. So in case of the power usage entities, they should be called:

for example.

I can advise you to:

I will be further investigating this to see if i can ensure unique id generation.

Thanks for your reply!

ddcbe commented 4 years ago

Hi,

thanks for the reply. I did as you suggested but the result is still the same. I also tried to rename the crownstone in the app so the get another name but it didn't help so far. Let me know if you need any further information, ....

Thanks!

RicArch97 commented 4 years ago

I believe i have found the issue, update will come asap!

ddcbe commented 4 years ago

That's fast! Awesome! Thanks for looking into this. The crownstones are now showing their full potential for me!

RicArch97 commented 4 years ago

Issue should be fixed in release 1.5.1

It is recommended to remove the integration and re-add it again after updating, because of the new ID's that will be generated (to avoid duplicates).

Let us know if it works correctly now!

hillstub commented 4 years ago

For me that did the job. However, after removing the integration and installing it again, I got a lot of *_2 entities (e.g. light.bedlamp_2). To get rid of that, I had to remove the crownstone entries from .storage/core.device_registry and .storage/core.entity_registry.

RicArch97 commented 4 years ago

For me that did the job. However, after removing the integration and installing it again, I got a lot of *_2 entities (e.g. light.bedlamp_2). To get rid of that, I had to remove the crownstone entries from .storage/core.device_registry and .storage/core.entity_registry.

Hmm that basically means the "old" entity id's still exist in home assistant after unloading an integration. Not sure if Home Assistant removes these by itself after a while, or that a restart is required.

I guess the best way to start clean is by removing the integration, restarting HA and then adding the integration again

hillstub commented 4 years ago

I thought I did restart Home Assistant after removing the integration, so you might be right in that it doesn't clean up properly..

jonathanhofman81 commented 4 years ago

I indeed removed the integration before updating and added it again after updating. That seems to work as expected (I didn't had duplicates). Furthermore, now all devices have a power usage entity. So that seems to work nice. That was a nice quick fix. Tnx!

ddcbe commented 4 years ago

Thanks! It works perfect! Great job!

RicArch97 commented 3 years ago

Added support for energy usage measurements in version 1.6.0.