Skip to content

Conversation

@lukaslisowski
Copy link

@lukaslisowski lukaslisowski commented Jun 27, 2025

Description:
This PR changes the type of the power (watt) parameter for the sonnenbatterie.discharge_battery and charge_battery services from str to int to support the use of templates in automations.

Reason:
Previously, the service accepted the power value as a string. When using templates, this often resulted in a string with extra quotes, which caused parsing errors like:

invalid literal for int() with base 10: '"762"'

This occurred during later parsing of the watt value in the code.

By changing the parameter type to int, both templated and direct numeric values are now handled correctly, allowing for smoother integration in automations and avoiding type conversion errors.

@lukaslisowski lukaslisowski reopened this Jun 27, 2025
@lukaslisowski lukaslisowski changed the title Lukaslisowski patch 1 Change type of power (watt) from string to integer for discharge_battery service Jun 27, 2025
@lukaslisowski lukaslisowski changed the title Change type of power (watt) from string to integer for discharge_battery service Change type of power (watt) from string to integer for discharge_battery/charge_battery service Jun 27, 2025
Repository owner deleted a comment from ginlonet Jun 29, 2025
@RustyDust
Copy link
Collaborator

Adding this PR would break the actions of the integration as can be verified in the developer tools, e.g. by running either the "charge_battery" or "discharge_battery" functions from there.

@lukaslisowski
Copy link
Author

Yes, you're right. I’ve updated the service definition, it should be fixed now. I’ve tested it locally.

@lukaslisowski lukaslisowski changed the title Change type of power (watt) from string to integer for discharge_battery/charge_battery service Add support for templates in automations in discharge_battery/charge_battery service Jun 29, 2025
@lukaslisowski lukaslisowski marked this pull request as draft June 30, 2025 17:38
@lukaslisowski lukaslisowski marked this pull request as ready for review June 30, 2025 17:43
@RustyDust
Copy link
Collaborator

Yes, you're right. I’ve updated the service definition, it should be fixed now. I’ve tested it locally.

Sorry, my machine used for testing broke and it took me a while to get a replacement up and running.
Anyway, while the last updates to your patch fixes the services the actions still stay broken. Also, the function descriptions in the README would need updating as well.

broken_Action_2 broken_action

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