Mas2112 / solarwatt-energymanager-homeassistant

A SOLARWATT EnergyManager Home Assistant custom component.
MIT License
17 stars 3 forks source link

Can't connect to Energy Manager flex #14

Closed olgru closed 1 year ago

olgru commented 1 year ago

My setup: Home Assistant 2023.4.6 Supervisor 2023.04.1 Operating System 10.1 Frontend 20230411.1 - latest on Proxmox 7.4-3 server.

I have a fronius Symo 3.0.3-M, a BMW flex Battery and the Solarwatt Energy manager flex (there is paper-ui with openHAB on it?!). The manager works, I can access it via http (and password); HAS and Solarsystem are in same IP subnet.

After installing this integration using HACS, I try to add the integration. After I enter the device IP in the host field, I got "Unkown error occured".

This is the log:

traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/solarwatt_energymanager/energy_manager.py", line 31, in test_connection raise CannotParseData solarwatt_energymanager.energy_manager.CannotParseData During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/config/custom_components/solarwatt_energymanager/config_flow.py", line 63, in async_step_user serial_number = await validate_host(user_input) File "/config/custom_components/solarwatt_energymanager/config_flow.py", line 32, in validate_host serial_number = await eman.test_connection() File "/usr/local/lib/python3.10/site-packages/solarwatt_energymanager/energy_manager.py", line 33, in test_connection raise CannotParseData solarwatt_energymanager.energy_manager.CannotParseData During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper result = await method(view, request, data, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure result = await self._async_handle_step( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/config/custom_components/solarwatt_energymanager/config_flow.py", line 64, in async_step_user except em.CannotConnect: AttributeError: module 'solarwatt_energymanager' has no attribute 'CannotConnect'


AND: I found a JSON link for this Solarwatt Energy Manager FLEX where all objects and data can be found! http://local-ip/rest/items The outcome of this call is a full list of data and individual likes for items. An item link looks like:


{"link":"http://192.168.x.xx/rest/items/solarwattBattery_batteryflex_BatteryFlex_0BFFAE_houseChannelGroup_housePowerConsumption","state":"-0.5 W","stateDescription":{"pattern":"%.2f %unit%","readOnly":true,"options":[]},"editable":false,"type":"Number:Power","name":"solarwattBattery_batteryflex_BatteryFlex_0BFFAE_houseChannelGroup_housePowerConsumption","label":"House Power Consumption","tags":[],"groupNames":[]}

Mas2112 commented 1 year ago

I think you have the newer energy manager flex, which isn't supported by this integration. The data interfaces are completely different.

On Fri, May 5, 2023, 10:00 Oliver @.***> wrote:

Running HAS 2023.4.6 on with Hassio on Proxmox server.

I have a fronius, a BMW flex Battery and the Solarwatt Energy manager. The manager works, I can access it via http.

After installing this integration using HACS, I try to add the integration. After I enter the device IP in the host field, I got "Unkown error occured". This is the log:

traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/solarwatt_energymanager/energy_manager.py", line 31, in test_connection raise CannotParseData solarwatt_energymanager.energy_manager.CannotParseData During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/config/custom_components/solarwatt_energymanager/config_flow.py", line 63, in async_step_user serial_number = await validate_host(user_input) File "/config/custom_components/solarwatt_energymanager/config_flow.py", line 32, in validate_host serial_number = await eman.test_connection() File "/usr/local/lib/python3.10/site-packages/solarwatt_energymanager/energy_manager.py", line 33, in test_connection raise CannotParseData solarwatt_energymanager.energy_manager.CannotParseData During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper result = await method(view, request, data, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure result = await self._async_handle_step( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/config/custom_components/solarwatt_energymanager/config_flow.py", line 64, in async_step_user except em.CannotConnect: AttributeError: module 'solarwatt_energymanager' has no attribute 'CannotConnect'

— Reply to this email directly, view it on GitHub https://github.com/Mas2112/solarwatt-energymanager-homeassistant/issues/14, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABJLA27Q35M7SNQPFFKVELXESXQPANCNFSM6AAAAAAXWYYYBQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

olgru commented 1 year ago

I think so, too.

While -logically - I understand what to do, I don't know how. I have no experience in reading a JASON to an array, do related string operations, add Home assistant like attributes and parse everything as sensors and entities to Home Assistant. I've never done this and I never found a good documentation on how to. This is my challange:

So I hoped, when I share the details here, that you might be able to integrate this easily to your code. I'm sorry, to hear that this is completely different.

Mas2112 commented 1 year ago

The editor of choice is Visual Studio Code. Python is quite easy to learn if you know programming already. Essentially you just need to use http to get JSON data from the energy manager flex, then parse the data and send it to home assistant.

You can try to copy this project and try to adapt it to the new energy manager flex.

This integration is basically split into two projects.

https://github.com/Mas2112/solarwatt-energymanager-py

The above project makes the http request and parses the JSON into an object.

The home assistant project makes the data available to home assistant.

I would just copy the code from the two projects into one project and just try to adapt it.

Here is an article on how to create a custom component.

https://aarongodfrey.dev/home%20automation/building_a_home_assistant_custom_component_part_1/

On Sat, May 6, 2023, 18:07 Oliver @.***> wrote:

I think so, too.

While -logically - I understand what to do, I don't know how. I have no experience in reading a JASON to an array, do related string operations, add Home assistant like attributes and parse everything as sensors and entities to Home Assistant. I've never done this and I never found a good documentation on how to. This is my challange:

  • Github
  • Python?
  • find a good editor
  • I can do VBscript, PHP, Mysql, html (of course), Turbo Pascal, BasicV7, Cobol, a bit c++, AutoIT stuff and everything a scripting guy might know. But this world here - with Git, Python and all the YAML/Jason formats - I never found a way into it. Maybe I'm just too old in the meantime...

So I hoped, when I share the details here, that you might be able to integrate this easily to your code. I'm sorry, to hear that this is completely different.

— Reply to this email directly, view it on GitHub https://github.com/Mas2112/solarwatt-energymanager-homeassistant/issues/14#issuecomment-1537172716, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABJLA5IRR73J4WCPYMWBOTXEZZM5ANCNFSM6AAAAAAXWYYYBQ . You are receiving this because you commented.Message ID: @.*** .com>

olgru commented 1 year ago

Thanks for the links. I read a bit deeper through your code yesterday. I'll try my first steps... :-)

Thank you again.