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

Integration broke Home Assistant 2021.8.0 #16

Closed
adriaanh opened this issue Aug 5, 2021 · 78 comments · Fixed by #18 or #32
Closed

Integration broke Home Assistant 2021.8.0 #16

adriaanh opened this issue Aug 5, 2021 · 78 comments · Fixed by #18 or #32

Comments

@adriaanh
Copy link

adriaanh commented Aug 5, 2021

I installed this integration via HACS and rebooted the system. After reboot, I added the following to my configuration.yaml. I have the ecu-r connected through wifi as per instruction and the secret has the ip address of the wifi connected ECU-r.

apsystems_ecur:	
  host: !secret apsystems_ecur_host

After rebooting, home assistant wouldn't start. I had to go back to a previous snapshot in order to get HA working again. No issues in the logs. Is this an issue with compatibility of home assistant?

I have the ECU-r with QS1 inverters, and connected both via WiFi and ethernet.

Thanks!

@adriaanh
Copy link
Author

adriaanh commented Aug 5, 2021

I'm going to try it out on an empty home assistant environment to check whether it fails there as well.

@HAEdwin
Copy link
Collaborator

HAEdwin commented Aug 5, 2021

Configuration.yaml should look like this (example):

apsystems_ecur:
    host: 172.16.0.5

The latest core release of HA (core-2021.8.0 and higher) introduced a renamed parameter for Voltage (ELECTRIC_POTENTIAL_VOLT) !!

So after installing using HACS you have to patch (if you are using core-2021.8.x):
Line 30 and 67 in sensor.py from VOLT to ELECTRIC_POTENTIAL_VOLT

Do not forget to reboot. Btw what is your current ECU-R firmware version?
Also take a look here: [https://community.home-assistant.io/t/apsystems-aps-ecu-r-local-inverters-data-pull/260835/359]

@HAEdwin
Copy link
Collaborator

HAEdwin commented Aug 5, 2021

I have the ECU-r with QS1 inverters, and connected both via WiFi and ethernet.

Make sure you've added the WiFi connected IP-address to the configuration.yaml not the ethernet connected IP-address

@adriaanh
Copy link
Author

adriaanh commented Aug 5, 2021

Thanks for the quick response! I have firmware 2.0xx

I have validated the setup with a clean install of 2021.8.X with the changes you proposed to VOLT. I doublechecked the IP-address, which is the correct one. Still Home Assistant wouldn't start anymore.

I have the following logs (checked with ha-cli:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] udev.sh: executing... 
[cont-init.d] udev.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
2021-08-05 13:02:08 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration apsystems_ecur which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-08-05 13:02:08 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

Supervisor logs:

21-08-05 13:02:01 INFO (SyncWorker_1) [supervisor.docker.interface] Restarting ghcr.io/home-assistant/qemux86-64-homeassistant
21-08-05 13:02:01 INFO (MainThread) [supervisor.api.proxy] Home Assistant WebSocket API error: Received message 8:1000 is not str
21-08-05 13:02:01 INFO (MainThread) [supervisor.api.proxy] Home Assistant WebSocket API connection is closed
21-08-05 13:02:07 INFO (MainThread) [supervisor.homeassistant.core] Wait until Home Assistant is ready
21-08-05 13:02:09 INFO (MainThread) [supervisor.resolution.evaluate] Starting system evaluation with state CoreState.RUNNING
21-08-05 13:02:09 INFO (MainThread) [supervisor.resolution.evaluate] System evaluation complete
21-08-05 13:02:40 ERROR (MainThread) [supervisor.homeassistant.api] Error on call http://172.30.32.1:8123/api/config: 
21-08-05 13:02:42 ERROR (MainThread) [supervisor.homeassistant.api] Error on call http://172.30.32.1:8123/api/config: 
21-08-05 13:03:12 ERROR (MainThread) [supervisor.homeassistant.api] Error on call http://172.30.32.1:8123/api/config: 

@adriaanh
Copy link
Author

adriaanh commented Aug 5, 2021

Ok, I tried again without an ethernet connection (so only WiFi is connected). Still the same response..

@hofvanta
Copy link

hofvanta commented Aug 5, 2021

I also have the ECU 2.0 and problems with HA. It would not start sometimes. After disabling apsystems_ecur is coming back again. Has something to do with the unstable communication with the ECU which influence the startup of HA.

@adriaanh
Copy link
Author

adriaanh commented Aug 5, 2021

There is sadly not much information in the debug logs of Home Assistant. It does not show the front-end, and in the log there is only the following message (regarding the custom_component).

2021-08-05 16:10:58 DEBUG (MainThread) [custom_components.apsystems_ecur] Querying ECU

Memory is blowing up however, so something is going wrong here.

@hofvanta
Copy link

hofvanta commented Aug 5, 2021

Yes I have the same. Processing or waiting on ECU seems like.

@adriaanh
Copy link
Author

adriaanh commented Aug 5, 2021

Ok, I think I have an idea what the issue is. It seems that it will not get the correct ecu_id populated from the raw data. When I hardcode the ecu_id in the code it sort of works. It does not fetch the (correct) data, but at least it doesn't fail. It tries to get the data, but I think it has the same problem as getting the data from the ecu_id: the raw response seems to be different.

self.ecu_id = 'APS1100280002'+myECUID+"END'

Home assistant logs:

2021-08-05 20:01:55 DEBUG (MainThread) [custom_components.apsystems_ecur] Querying ECU
2021-08-05 20:01:58 WARNING (MainThread) [custom_components.apsystems_ecur] Using cached data from last successful communication from ECU. Error: [Errno 113] Connect call failed ('192.168.98.82', 8899)
2021-08-05 20:01:58 DEBUG (MainThread) [custom_components.apsystems_ecur] Returning {'data_from_cache': True, 'querying': True}
2021-08-05 20:01:58 DEBUG (MainThread) [custom_components.apsystems_ecur] Finished fetching apsystems_ecur data in 3.089 seconds

Maybe an idea to:

  • Let people hardcode the ECU-ID within the integration?
  • Let hem selecft the firmware version
  • And then fetch the data accordingly?

Or trying different responses might also help?

@ksheumaker
Copy link
Owner

ksheumaker commented Aug 5, 2021

Taking a different code path for a 2.0 or PRO ECU shouldn't be a big deal if we can figure out how to decode the data.

I took a look at the test script on the tweakers site, it doesn't issue the all the same queries the integration does. The first one the integration does is tells us the the ECU ID, firmware version, lifetime energy, today energy, current power, etc. This query is:

APS1100160001END

Can someone run that on the 2.0 device and provide the output of what is returned?

@adriaanh
Copy link
Author

adriaanh commented Aug 5, 2021

Ok, I added a lot of debug messages in the code. I hardcoded the ecu_id. Getting the following messages (XXXX = ecu_id I put manually in (of course the correct one, not XXXX ;-) )

2021-08-05 20:51:27 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] ecu_raw_data: b'APS1201160001XXXXXXXXXXXXXX\x00\x00\x085\x00\x00\x00*\x00\x00\x07: !\x08\x05 I\x00\x00\x03\x00\x0310015ECU_R_PRO_2.0.1016Europe/Amsterdam\x80\x97\x1b\x02\xaa?`\xc5\xa8y\xdbi00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00END\n'
2021-08-05 20:51:27 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Data received. Now processing data
2021-08-05 20:51:27 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Processing ecu data - Check checksum
2021-08-05 20:51:27 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Processing ecu data - Checksum complete
2021-08-05 20:51:27 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Processing data complete. Now query inverter
2021-08-05 20:51:27 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Inverter cmd: APS1100280002XXXXXXXXXXXXEND

2021-08-05 20:51:27 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Send read from socket attempt 1
2021-08-05 20:51:27 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Writer encode to utf 8. Now drain
2021-08-05 20:51:27 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Within try except block -> wait for read from socket

Looking at the code, it seems that it stops working when it is trying to get the inverter data. Looking at the functions and logic, it stops working at function async_query_ecu() in APSystemsECUR.py. The logic:

  1. OK: async_query_ecu -> getting the ecu raw data
  2. OK: async_query_ecu -> processing the ecu data
  3. OK: processing_ecu_data() > checksum ecu data
  4. NOT OK: async_query_ecu -> async_send_read_from_socket inverter data (lines 112-113)
cmd = self.inverter_query_prefix + self.ecu_id + self.inverter_query_suffix
self.inverter_raw_data = await self.async_send_read_from_socket(cmd)

And then it stops at the try/except block on lines 95-96:

            try:
                return await asyncio.wait_for(self.async_read_from_socket(), 
                    timeout=self.timeout)
            except Exception as err:
                pass

Anyone any idea what's going on?

@adriaanh
Copy link
Author

adriaanh commented Aug 5, 2021

@ksheumaker When sending the APS1100160001END command, I get the following response:

b'APS1201160001XXXXXXXXXXXXXX\x00\x00\x085\x00\x00\x00\xb2\x00\x00\x074 !\x08\x05 \x13W\x00\x03\x00\x0310015ECU_R_PRO_2.0.1016Europe/Amsterdam\x80\x97\x1b\x02\xaa?`\xc5\xa8y\xdbi00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00END\n'

@ksheumaker
Copy link
Owner

2021-08-05 20:51:27 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Inverter cmd: APS1100280002XXXXXXXXXXXXEND

I'm assuming the XXXXXX are replaced with the correct ECU_ID?

And on your question on lines 95-96 that's reading from the socket and awaiting a response. It should timeout after 5 seconds. But you can add a debug statement above the pass in the Exception block like this

_LOGGER.info(f"Failed on asyncio.wait: {err}")

And maybe we can get a little more details on if there was an exception and what it is

@adriaanh
Copy link
Author

adriaanh commented Aug 5, 2021

Yes I replaced with the correct values ;-).

The script never comes to the Exception block, I have a debug message there already, but it doesn't trigger/show up.

@ksheumaker
Copy link
Owner

There was some talk about closing the socket and re-opening it between queries? are you doing that? if not replace the async_query_ecu function with this:

    async def async_query_ecu(self):
        self.reader, self.writer = await asyncio.open_connection(self.ipaddr, self.port)
        _LOGGER.info(f"Connected to {self.ipaddr} {self.port}")

        cmd = self.ecu_query
        self.ecu_raw_data = await self.async_send_read_from_socket(cmd)

        self.process_ecu_data()

        if "ECU_R_PRO" in self.firmware:
            self.writer.close()
            _LOGGER.info(f"Re-connecting to ECU_R_PRO on {self.ipaddr} {self.port}")
            self.reader, self.writer = await asyncio.open_connection(self.ipaddr, self.port)

        cmd = self.inverter_query_prefix + self.ecu_id + self.inverter_query_suffix
        self.inverter_raw_data = await self.async_send_read_from_socket(cmd)


        if "ECU_R_PRO" in self.firmware:
            self.writer.close()
            _LOGGER.info(f"Re-connecting to ECU_R_PRO on {self.ipaddr} {self.port}")
            self.reader, self.writer = await asyncio.open_connection(self.ipaddr, self.port)

        cmd = self.inverter_signal_prefix + self.ecu_id + self.inverter_signal_suffix
        self.inverter_raw_signal = await self.async_send_read_from_socket(cmd)

        self.writer.close()

        data = self.process_inverter_data()
        data["ecu_id"] = self.ecu_id
        data["today_energy"] = self.today_energy
        data["lifetime_energy"] = self.lifetime_energy
        data["current_power"] = self.current_power

        return(data)

@ksheumaker
Copy link
Owner

I'm assuming this lines up with your system?

Qty inverters 3
FW ECU_R_PRO_2.0.1
Lifetime Energy 210.1
Today Energy 18.44
Current Power 178

@adriaanh
Copy link
Author

adriaanh commented Aug 5, 2021

@ksheumaker Yes it does.

I replaced the function with the new one. Looks better, no freeze until now, but still no (correct) data, but now there is a message abount inverter type 806!

2021-08-05 21:10:09 INFO (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Connected to 192.168.98.82 8899
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Send read from socket attempt 1
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Writer encode to utf 8. Now drain
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Within try except block -> wait for read from socket
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Processing ecu data - Check checksum
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Processing ecu data - Checksum complete
2021-08-05 21:10:09 INFO (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Re-connecting to ECU_R_PRO on 192.168.98.82 8899
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Send read from socket attempt 1
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Writer encode to utf 8. Now drain
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Within try except block -> wait for read from socket
2021-08-05 21:10:09 INFO (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Re-connecting to ECU_R_PRO on 192.168.98.82 8899
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Send read from socket attempt 1
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Writer encode to utf 8. Now drain
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Within try except block -> wait for read from socket
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Processing inverter data - Check checksum
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Processing inverter data - Checksum complete
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Processing signal data - Check checksum
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Processing signal data - Checksum complete
2021-08-05 21:10:09 WARNING (MainThread) [custom_components.apsystems_ecur] Using cached data from last successful communication from ECU. Error: Unsupported inverter type 806
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur] Returning {'data_from_cache': True, 'querying': True}
2021-08-05 21:10:09 DEBUG (MainThread) [custom_components.apsystems_ecur] Finished fetching apsystems_ecur data in 0.704 seconds

@ksheumaker
Copy link
Owner

Ok, what type do you have, are they QS1? If so add "806" to array at line 35.

@adriaanh
Copy link
Author

adriaanh commented Aug 5, 2021

YES! Added '806' to the QS1 array and rebooted. Now getting all kinds of data :-)

@adriaanh
Copy link
Author

adriaanh commented Aug 5, 2021

Shall I provide a pull request with the changes made? (new function + adding 806 to the QS1 data)

@ksheumaker
Copy link
Owner

Sure if you'd like to that would be great!

@adriaanh
Copy link
Author

adriaanh commented Aug 6, 2021

Worked for quite some time today, but stopped working again (HA unresponsive).

2021-08-06 13:46:53 DEBUG (MainThread) [custom_components.apsystems_ecur] Finished fetching apsystems_ecur data in 0.886 seconds
2021-08-06 13:47:53 DEBUG (MainThread) [custom_components.apsystems_ecur] Querying ECU
2021-08-06 13:47:53 INFO (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Connected to 192.168.98.82 8899
2021-08-06 13:47:53 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Send read from socket attempt 1
2021-08-06 13:47:53 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Writer encode to utf 8. Now drain
2021-08-06 13:47:53 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Within try except block -> wait for read from socket

@adriaanh
Copy link
Author

adriaanh commented Aug 6, 2021

This might actually be the same kind of issue: https://stackoverflow.com/questions/41932359/timeout-for-python-coroutines

@adriaanh
Copy link
Author

adriaanh commented Aug 6, 2021

Tried to debug again. When I put the following in the function where it stops, I get the following. Seems that we need to create something to stop the while loop if the data is rubbish:

        while end_data != self.recv_suffix:
            self.read_bytes = await self.reader.read(self.recv_size)
            self.read_buffer += self.read_bytes
            size = len(self.read_buffer)
            end_data = self.read_buffer[size-4:]
            _LOGGER.debug(f"Read buffer {size} with end data {end_data}")

Debug logs:

2021-08-06 15:55:32 INFO (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Connected to 192.168.98.82 8899
2021-08-06 15:55:32 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Send read from socket attempt 1
2021-08-06 15:55:32 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Writer encode to utf 8. Now drain
2021-08-06 15:55:32 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Within try except block -> wait for read from socket
2021-08-06 15:55:33 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Read buffer 0 with end data b''
2021-08-06 15:55:33 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Read buffer 0 with end data b''
2021-08-06 15:55:33 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Read buffer 0 with end data b''
2021-08-06 15:55:33 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Read buffer 0 with end data b''
2021-08-06 15:55:33 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Read buffer 0 with end data b''
2021-08-06 15:55:33 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Read buffer 0 with end data b''
2021-08-06 15:55:33 DEBUG (MainThread) [custom_components.apsystems_ecur.APSystemsECUR] Read buffer 0 with end data b''

@ksheumaker
Copy link
Owner

I didn't mean to close this - I added a change to the latest version that incorporates the suggestion from the stack overflow post. Your ECU seems to be less reliable in sending out data than mine, since i've never run into getting 0 bytes back from the socket. Let me know if it helps you.

@adriaanh
Copy link
Author

adriaanh commented Aug 6, 2021

Thanks for adding these changes! I have installed the latest version. It doesn't block Home Assistant, however, does not connect to the ECU. I tried manually and no 'asnwer' there either. It connects, provides the ECU_ID, but doesn't provide the inverter data.

After I rebooted the ECU all started working. I suspect the ECU doesn't like all the requests or something. Maybe lowering the number of requests would help.

Possible to enable a configuration that indicates the update_interval? I can do that with an automation, but integrated in the configuration would be slick.

@ksheumaker
Copy link
Owner

added support for adding

scan_interval: [SECS]

to the configuration, default is 60 if you leave it out. Let me know what value you seems to be safe with your ECU

@hofvanta
Copy link

I had a static DHCP binding, and ECU didnt accept to offer after a while. Static Wifi IP is not possible, only for the LAN interface on a ECU-R. The router (dhcp server) was for sure not the problem (tested with spoofing the Wifi MAC address with old Wifi dongle). SO the ECU-R now is connected by LAN, but spontaneous loose connection after 72 hours. Reason not found yet. Can be that the socket is in use and not cleared by the HA ECU integration. You cannot verify it, because Arago account is not known (Arago is the OS op en ECU-R and able to telnet to it)

@HAEdwin
Copy link
Collaborator

HAEdwin commented Jan 13, 2022

The sync query contains socket close and can be used to try when you modify __init__.py
Replace data = await self.ecu.async_query_ecu() with data = self.ecu.query_ecu() around line 73

@HAEdwin
Copy link
Collaborator

HAEdwin commented Jan 14, 2022

I discovered that this function reuses the same socket to send multiple commands, so that has to be rewritten...

@ksheumaker
Copy link
Owner

Didn't mean to close this, but I created a new version which will add a 1 second sleep between socket close and opens to try and prevent the ECU from being overloaded when using the ECU_R_PRO. Hopefully this will help, we can try increasing the sleep time as well to see if that helps at all.

@ksheumaker ksheumaker reopened this Jan 22, 2022
@hofvanta
Copy link

Cool, tx, I have it run. Will monitor from now on with ECU_R_PRO if it keeps working. Fingers crossed!

@renini
Copy link

renini commented Jan 25, 2022

@adriaanh I have the same one, from the gui this seems only like sunspec via modbus over the extra rs485 port. For me the drop down "Address" has the options for address assignments between 1-255. I think this is related to how modbus works. Can't find any modbus over tcp option in the gui, so only rs485 for now i guess. So probably the tcp/8899 is the way to go to read this locally for the time being, unless the sunspec rest option gets implemented someday...

@HAEdwin does your older ECU-R, also have an RS485 port. next to the ethernet port?

@ksheumaker
Copy link
Owner

Multiple changes were done in 1.1.2 to hopefully increase stability with ECU-C and ECU_R_PRO devices. Please update to the latest version and if you still have issues please open a new github issue.

@dewi-ny-je
Copy link

dewi-ny-je commented Apr 3, 2022

@hofvanta
Copy link

hofvanta commented Apr 4, 2022

I didnt try it yet because of RS485 delivery delays. Should be nice if you can experience with the EW-11 is possible in combination with APS ECU_R_PRO.

@dewi-ny-je
Copy link

I didnt try it yet because of RS485 delivery delays. Should be nice if you can experience with the EW-11 is possible in combination with APS ECU_R_PRO.

It's used all the time, I cannot repurpose it.
I have another RS232-RS485 module which I could use with R-Pi or ESP8266, but I have little time recently so given the time it would take to setup everything I may simply set the module multiscrape to parse the local web page.

@tv3
Copy link

tv3 commented Apr 4, 2022

For the scraper part, you can check my repo.

https://github.com/tv3/homeassistant-apsystems_ecur

It's a fork from this repo where I worked on getting rid of the whole tcp communications.

With Kyle I wanted it to integrate into his integration, but it has been silent for some time. So I might work on a separate integration for any ecu with the internal web interface (I have an Ecu_r_pro).

@dewi-ny-je
Copy link

For the scraper part, you can check my repo.

https://github.com/tv3/homeassistant-apsystems_ecur

It's a fork from this repo where I worked on getting rid of the whole tcp communications.

With Kyle I wanted it to integrate into his integration, but it has been silent for some time. So I might work on a separate integration for any ecu with the internal web interface (I have an Ecu_r_pro).

Yes I was thinking about your module too. Why haven't you refactored it based on the latest version of Kyle's module? Especially since he has been silent.

@dewi-ny-je
Copy link

For the scraper part, you can check my repo.

https://github.com/tv3/homeassistant-apsystems_ecur

It's a fork from this repo where I worked on getting rid of the whole tcp communications.

With Kyle I wanted it to integrate into his integration, but it has been silent for some time. So I might work on a separate integration for any ecu with the internal web interface (I have an Ecu_r_pro).

BTW you didn't enable the Issues page on your repo. Also, your integration works just fine with the Ethernet address, the Wifi is not required.

@tv3
Copy link

tv3 commented Apr 4, 2022

I know it works on both Ethernet and WiFi. Been running it for weeks. As for issues etc. There wasn't any plan yet to create a separate integration. If I do, I will first need to find some time to clean it up. For now it is still a copy of Kyle's repo with hacks from my side.

@dewi-ny-je
Copy link

I know it works on both Ethernet and WiFi. Been running it for weeks. As for issues etc. There wasn't any plan yet to create a separate integration. If I do, I will first need to find some time to clean it up. For now it is still a copy of Kyle's repo with hacks from my side.

Anyway I just installed it and it works just fine.
I set 305 seconds as interval because setting the same as the source data worries me that sometimes I'll get the old data again. Maybe a check could be done, and if identical (given the timestamp), repeat the polling 5 seconds later. Hopefully the 300 s would then start from the latest measurement, not from the planned one which proved to be too early.

@tv3
Copy link

tv3 commented Apr 4, 2022

Iirc there is a check on wether new data has arrived (time stamp check).
Also disable integration on sundown.

@dewi-ny-je
Copy link

dewi-ny-je commented Apr 9, 2022

Iirc there is a check on wether new data has arrived (time stamp check). Also disable integration on sundown.

Has you integration stopped working for you too in the last few days? Maybe after the latest update from HA 2022.4.x?

I get

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 335, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/apsystems_ecur/__init__.py", line 195, in async_setup_entry
    inverters = coordinator.data.get("inverters", {})
AttributeError: 'NoneType' object has no attribute 'get'

And

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 190, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 150, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/apsystems_ecur/__init__.py", line 109, in update
    raise Exception(f"Somehow data doesn't contain a valid ecu_id")
Exception: Somehow data doesn't contain a valid ecu_id

The Web gui works as usual.

@hofvanta
Copy link

hofvanta commented Apr 9, 2022

Same here.

@dewi-ny-je
Copy link

I restarted the ECU and now it works. @tv3 have you experienced anything similar recently? I find strange that the Web guide from the browser works but your integration, scraping the Web interface, doesn't, even after multiple restarts of HA.

@dewi-ny-je
Copy link

I just checked your repo and I see some test webpages. For info, my ECU-R-PRO does not offer the following ones anymore:

old_energy_graph_monthly
old_energy_graph_weekly
old_energy_graph_yearly
old_power_graph-daytime
old_power_graph-dusk

You are not using them, but for information...

The bare ones:

old_energy_graph
old_power_graph

are still working providing a text only summary. So I don't understand why your integration stopped working.

@tv3
Copy link

tv3 commented Apr 12, 2022

@dewi-ny-je the monthly/weekly etc are not real URL's.

you need to POST on http:///index.php/realtimedata/old_energy_graph
and supply additional data eg: period=weekly (orperiod=yearly etcetera)

@dewi-ny-je
Copy link

@dewi-ny-je the monthly/weekly etc are not real URL's.

you need to POST on http:///index.php/realtimedata/old_energy_graph and supply additional data eg: period=weekly (orperiod=yearly etcetera)

Thanks.
Any feedback on the issue @hofvanta and I had? the web gui working but the integration not? If it happens again I'll provide further feedback, for now it's working after restarting the ECU

@dewi-ny-je
Copy link

Today:

Using cached data from last successful communication from ECU. Error: index out of range

@tv3
It's not holding whole week before I need to restart the ecu in order to get again data.

@tv3
Copy link

tv3 commented Apr 20, 2022

You're probably using the socket implementation, instead of the http version of the query ecu function.

@dewi-ny-je
Copy link

You're probably using the socket implementation, instead of the http version of the query ecu function

I thought your version was only http, I have to check where's the setting for that. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants