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

Missing entitys for "Daily fixed energy" instances #1677

Closed
5 tasks done
Phil1988 opened this issue May 26, 2023 · 13 comments
Closed
5 tasks done

Missing entitys for "Daily fixed energy" instances #1677

Phil1988 opened this issue May 26, 2023 · 13 comments
Labels
bug Something isn't working daily-fixed

Comments

@Phil1988
Copy link

System Health details

System Information

version core-2023.5.4
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.10.11
os_name Linux
os_version 6.1.25
arch x86_64
timezone Europe/Berlin
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 4947
Installed Version 1.31.0
Stage running
Available Repositories 1283
Downloaded Repositories 7
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 10.1
update_channel stable
supervisor_version supervisor-2023.04.1
agent_version 1.5.1
docker_version 23.0.3
disk_total 30.8 GB
disk_used 6.1 GB
healthy true
supported true
board ova
supervisor_api ok
version_api ok
installed_addons Studio Code Server (5.6.0), Terminal & SSH (9.7.0)
Dashboards
dashboards 2
resources 1
views 8
mode storage
Recorder
oldest_recorder_run 24. Mai 2023 um 17:34
current_recorder_run 26. Mai 2023 um 17:09
estimated_db_size 200.64 MiB
database_engine sqlite
database_version 3.40.1

Checklist

  • I have read the FAQ to see if there is a known solution to my problem.
  • I have enabled debug logging for my installation.
  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of currently previous issues..

Describe the issue

When setting up a "Daily fixed energy" instance via the UI of Powercalc, I don't get any entitys when the unit is kWh.
The same with W as unit works as expected.

Not a big deal to switch, but I was very confused that using "kWh" doesnt give me anything usefull to integrate to my HA.

Reproduction steps

Go to settings -> devices & services -> Add integration -> search for "Powercalc" and select it-> select "Daily energy" -> Give it a name, set a value, choose "kWh" as unit, set intervall eg. to 15 sec and klick accept.

In "devices & services" under "powercalc" you can now see the new virtual device, that has no entity.
You can (re)configure it and change the unit to "W". After this you can see the entitys.
You can (re)configure it and change the unit again to "kWh". After this the entitys are gone.

Debug logs

there are no logs

Diagnostics dump or YAML config

No response

@Phil1988 Phil1988 added the bug Something isn't working label May 26, 2023
@bramstroker
Copy link
Owner

Thanks for reporting. will be fixed with #1679, which will be in next version I'll release today.

@bramstroker
Copy link
Owner

Fix has been released in v1.6.2. Please let me know if it is solved for you.

@Phil1988
Copy link
Author

Tested and confirm that it works now.
Thanks for the quick fix 👍

@Phil1988 Phil1988 reopened this Jun 3, 2023
@Phil1988
Copy link
Author

Phil1988 commented Jun 3, 2023

Sorry, but I have to re-open it.

The "power" entity is not working when "kWh" is seleved.

Additionally: Its buggy to insert low values in.
eg. you can not type 0.093 as value.

You can insert "93"
Then you can add a "0." in front
Then you can add a "0" in between those two. like
93
0.93
0.093

The "normal" way by just typing deletes the value while typing.
Its another bug I know.

@bramstroker
Copy link
Owner

Please don't report multiple/new issues in the same issue. Please create a new issue for that. Maybe related to #1675?

Regarding this issue.

The "power" entity is not working when "kWh" is selected.

This is correct and by design as there cannot be a power sensor when selecting kWh. Power is an instantaneous value and there is no way to derive that from a kWh value.

So when you select W you will get both a power and energy sensor
When you select kWh you only get an energy sensor.

I will add a note to the documentation to clarify this.

@bramstroker
Copy link
Owner

@Phil1988
Copy link
Author

Phil1988 commented Jun 4, 2023

I dont agree on that and it totally doesnt make any sense for me.
Powercalc has even "power" in its name and it should always give you both values as everything else is not intuitive and also missing for simply no reason.

You could then also say that watts is the unit for power and there is no way to integrate that to kWh.
So then you should leave the kWh entity away if someone enters the power.

  • Both would lead, in my understanding, in your add-on beeing less valuable.

They both correlate via time, so if you know what power (watts) a device is using, you integrate it via time (calculate it) to get the energy consumption in kWh - what you already do.
Other way:
If you know the energy consumption of a device in kWh you can also calculate the power by that known kWh.

To make it easier for you, you can simply calculate the power in watts by the given kWh value of the user via:
powerInWatts = valueEnteredAs_kWh / 24 and use this value always.
So you can internally convert it directly and dont have to add another function as you can use the one from your "power" that is already existing togive these two entitys.
So there is no magic here and its also not super complicated.

Adding it to the docs leaves this still as a bug of this (and I want to pint this out) in other aspects fantastic custom component for Home Assistant.

@bramstroker
Copy link
Owner

The reason I didn't implement was because of the on_time configuration option, which indicates how long the device is on per day.
When you fill in 800 W and on time 8 hours a day. It will account for 800W * 8h = 6.4kWh.
However I cannot show 800W for the power sensor 24/7 as that would be incorrect. The 800W needs to be shown only for 8 hours a day. I didn't see an easy way to do this without complicated timers and things like that, and I can't sense which time it should start and stop.
Could also show 6400 / 24 = 277W, but that would be even more incorrect and confusing for users.

Second reason I didn't implement was that the power sensor always has a static value, so it does not really have an added value in any way imo. This can also easily be achieved with a few lines of code with a template sensor.

@Phil1988
Copy link
Author

Phil1988 commented Jun 5, 2023

Thanks for your answer, but I still dont get it.

I can see the on_time also when selecting W:
image

When you fill in 800 W and on time 8 hours a day. It will account for 800W * 8h = 6.4kWh.

Which is totally correct

So how do you calculate/integrate this power sensor (W) on a daily limited on_time currently?
You somehow have to set it somewhere.
Better would be to let the user set a "turn on time" and an "turn off time", so every device gets a virtual power and energy entity at the right time.

But the on_time is in all cases I can think off not connected to my report.
I am only asking for calculating the energy (kWh) back to power (W) and give both entitys out.

If you are really 100% sure that you dont want to change it, its kind of "OK", but me and other users would appreciate a hint "if you select kWh you dont get a power entity" somewhere here:
image

@bramstroker
Copy link
Owner

So how do you calculate/integrate this power sensor (W) on a daily limited on_time currently? You somehow have to set it somewhere. Better would be to let the user set a "turn on time" and an "turn off time", so every device gets a virtual power and energy entity at the right time.

I do that by calculating the amount of kWh which needs to be added per day and increase the energy sensor with a proportional amount depending on the update_frequency configured (which is 30 minutes) by default.
So by default for the example above 6.4 / 48 = 0.1333 will be added on each update.
I have thought about a start / end time when developing this feature a year ago, but it was much more complicated to implement. And it won't allow for multiple start and end times a day. And what if the start and end time starts late in the evening and ends early in the morning? And more edge cases which complicates things.

Anyway what I can do is create the power sensor when you don't use the on_time function. That would be an easy addition and fix your request and for most others.

@Phil1988
Copy link
Author

Phil1988 commented Jun 6, 2023

Thanks @bramstroker for your fast responses and your interest to find a solution for that! :)

I also think that your idea of implementing it would suit most users.
Thanks!

@bramstroker
Copy link
Owner

Will be resolved with #1704

@bramstroker
Copy link
Owner

Released in v1.6.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working daily-fixed
Projects
None yet
Development

No branches or pull requests

2 participants