foogod / go-powerwall

A Go library for communicating with Tesla Powerwall appliances via the local-network API
MIT License
6 stars 7 forks source link

Cannot unmarshal number 60000000000 into Go struct field MeterAggregatesData.timeout of type int #6

Open sighmon opened 9 months ago

sighmon commented 9 months ago

Thanks so much for your library. This week I noticed that https://github.com/sighmon/homekit-powerwall stopped working, so looked into the logs and saw:

cannot unmarshal number 60000000000 into Go struct field MeterAggregatesData.timeout of type int

Feels similar to #4

Here's a sample of the output from /api/meters/aggregates from Powerwall running v23.36.3 aa269d35

"battery":{
    "last_communication_time":"2024-01-16T20:53:09.608153+10:30",
    "instant_power":2630,
    "instant_reactive_power":-1430,
    "instant_apparent_power":2993.6265632172626,
    "frequency":49.983000000000004,
    "energy_exported":166882,
    "energy_imported":219254,
    "instant_average_voltage":246.5,
    "instant_average_current":-56.400000000000006,
    "i_a_current":0,
    "i_b_current":0,
    "i_c_current":0,
    "last_phase_voltage_communication_time":"0001-01-01T00:00:00Z",
    "last_phase_power_communication_time":"0001-01-01T00:00:00Z",
    "last_phase_energy_communication_time":"0001-01-01T00:00:00Z",
    "timeout":60000000000,
    "num_meters_aggregated":1,
    "instant_total_current":-56.400000000000006,
},
sighmon commented 9 months ago

I managed to test a fix in PR #7 using https://github.com/sighmon/homekit-powerwall by adding the following line to my go.mod file:

replace github.com/foogod/go-powerwall => github.com/sighmon/go-powerwall v0.0.0-20240116104430-7e4a9dc82d72

andig commented 9 months ago

@sighmon seems this repo is dead. I have a maintained fork at https://github.com/andig/go-powerwall for time being. Feel free to use that.

sighmon commented 9 months ago

@andig I'm not sure just point to your fork will work as the module name won't match in go.mod. But if you merge all of the PRs from this repo and update the mod file it might be a good option.

andig commented 9 months ago

2/4 PRs are mine and merged, int64 is also fixed. Since I decided to go for a permanent fork, module name was changed.

sighmon commented 9 months ago

@andig I'm not seeing the fix here on main: https://github.com/andig/go-powerwall/blob/main/meters.go#L35

andig commented 9 months ago

Feel free to open PR against master.