Lorentz83 / esb2ha

Download electicity usage from esb.ie and upload it to Home Assistant
MIT License
2 stars 0 forks source link

Error when piping to HomeAssistant #2

Open CaptInsano opened 7 months ago

CaptInsano commented 7 months ago

Thanks a million for your work on this project, it is a great idea!

My Setup: HomeAssistant OS running as a VM Core: 2024.4.3 Supervisor: 2024.04.0 Operating System: 12.2 Frontend: 20240404.2

I have installed esb2ha via docker on my server and have the alias setup as per your documentation:

alias esb2ha='docker run --rm esb2ha:latest'

Getting the following error when trying to pipe data into home assistant (I am using single quotes for each flag data as some start with wildcards):

root@Tower:~# esb2ha pipe -esb_user 'XXXXXXXXXXX' -esb_password 'XXXXXXXXXXX' -mprn 'XXXXXXXXXX' -ha_server '192.168.X.XXX:8123' -ha_token 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' -ha_sensor 'sensor.esb_electricity_usage'
Downloading data...
Uploading data...
Sent 651 data points from 2023-04-12 18:00:00 +0100 IST to 2023-05-09 20:00:00 +0100 IST
Uploading data...
Sent 941 data points from 2023-05-10 00:00:00 +0100 IST to 2023-06-18 04:00:00 +0100 IST
Uploading data...
ERROR: cannot send statistics to Home Assistant: error invalid_format: expected a list for dictionary value @ data['stats']. Got None
Uploading data...
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/lorentz83/esb2ha/parse.Translate({{0xc00025a000, 0xb}, {0xc00025a00b, 0x8}, {0x714a0e, 0x1b}, {0xc000096140, 0x1, 0x1}})
        /tmp/src/parse/parse.go:287 +0x6d6
main.(*uploadCmd).upload(0xc0000981e0, {0x7a6cf0, 0x9d9a20}, {{0xc00025a000, 0xb}, {0xc00025a00b, 0x8}, {0x714a0e, 0x1b}, {0xc000096140, ...}})
        /tmp/src/esb2ha.go:192 +0xc9
main.(*uploadCmd).parseAndUpload(0xc0000981e0, {0x7a6cf0, 0x9d9a20}, {0x7a47a0?, 0xc0000ab170?})
        /tmp/src/esb2ha.go:179 +0x236
main.(*pipeCmd).Execute(0xc0000981e0, {0x7a6cf0, 0x9d9a20}, 0x146f6c98bb11?, {0x70?, 0x6c980108?, 0x146f25ef0728?})
        /tmp/src/esb2ha.go:248 +0x167
github.com/google/subcommands.(*Commander).Execute(0xc0000ca000, {0x7a6cf0, 0x9d9a20}, {0x0, 0x0, 0x0})
        /go/pkg/mod/github.com/google/subcommands@v1.2.0/subcommands.go:209 +0x37a
github.com/google/subcommands.Execute(...)
        /go/pkg/mod/github.com/google/subcommands@v1.2.0/subcommands.go:492
main.main()
        /tmp/src/esb2ha.go:33 +0x79

My sensor is set up as per your documentation (template value already existed in my setup):

image

image

If I just try the following command it works without error:

root@Tower:~# esb2ha download -esb_user 'XXXXXXXXXXXXX' -esb_password 'XXXXXXXXXXXXXX' -mprn 'XXXXXXXXXX'

Any help is greatly appreciated!

CaptInsano commented 6 months ago

Any advice on how to debug this further?

Thanks again

Lorentz83 commented 1 week ago

Hi, sorry for the very late answer. This is likely related to the bug #3

ESB changed format, so the script cannot parse it anymore.

CaptInsano commented 1 week ago

Thanks for the reply, no worries for the late answer.

Will watch this and the other issue #3 to monitor if a fix can be found.

Thanks again for your work

Lorentz83 commented 1 week ago

I've fixed the download, please try again.

Even, from a better reading of the error message, it looks more like the CSV downloaded from ESB was corrupted. Let me know if it works now. If it doesn't I need to add some better validation to avoid this crash