lux4rd0 / sense-collector

Sense Collector provides a way of collecting real-time data from the Sense Energy Monitor. Includes Grafana dashboards for visualizations of detected devices and smart plugs and their wattage, voltage, and amp utilization.
https://labs.lux4rd0.com/sense-collector/
GNU Affero General Public License v3.0
25 stars 4 forks source link

HTTP Error: 204 No Content AND 400 Bad Request #12

Closed televisi closed 2 weeks ago

televisi commented 7 months ago

Hi,

Great script! Unfortunately, for some reason my setup stopped working (it works 1/2 day and stops after that) and I have been trying to scratch my head to find out where the issue is.

My setup (all inside docker instance):

Environment variable used:

SENSE_COLLECTOR_TOKEN=t1.v2.eyJhbxxx
SENSE_COLLECTOR_MONITOR_ID=267xxx
TZ=Australia/Sydney
SENSE_COLLECTOR_HOST_HOSTNAME=ubuntu
SENSE_COLLECTOR_INFLUXDB_PASSWORD=12345678
SENSE_COLLECTOR_INFLUXDB_URL=http://192.168.1.26:32800/write?db=sense
SENSE_COLLECTOR_INFLUXDB_USERNAME=sensedb
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SENSE_COLLECTOR_DISABLE_HEALTH_CHECK=true
SENSE_COLLECTOR_DEBUG=true
SENSE_COLLECTOR_DEBUG_CURL=true
SENSE_COLLECTOR_DEBUG_IF=true
SENSE_COLLECTOR_DEBUG_SLEEPING=true
SENSE_COLLECTOR_DISABLE_HOST_PERFORMANCE=false

Error logs:

payload={"voltage":[248.2037353515625],"frame":17049350,"devices":[{"id":"always_on","name":"Always On","icon":"alwayson","tags":{"DefaultUserDeviceType":"AlwaysOn","DeviceListAllowed":"true","TimelineAllowed":"false","UserDeleted":"false","UserDeviceType":"AlwaysOn","UserDeviceTypeDisplayString":"Always On","UserEditable":"false","UserMergeable":"false"},"attrs":[],"w":318},{"id":"unknown","name":"Other","icon":"home","tags":{"DefaultUserDeviceType":"Unknown","DeviceListAllowed":"true","TimelineAllowed":"false","UserDeleted":"false","UserDeviceType":"Unknown","UserDeviceTypeDisplayString":"Unknown","UserEditable":"false","UserMergeable":"false"},"attrs":[],"w":140.02094},{"id":"solar","name":"Solar","icon":"solar_alt","tags":{"DefaultUserDeviceType":"Solar","DeviceListAllowed":"false","TimelineAllowed":"false","UserDeleted":"false","UserDeviceType":"Solar","UserDeviceTypeDisplayString":"Solar","UserEditable":"false","UserMergeable":"false"},"attrs":[],"w":6.2918267}],"deltas":[],"defaultCost":29.65,"channels":[458.02093505859375],"hz":50.01411437988281,"w":458.02093505859375,"c":13,"solar_w":6.2918267250061035,"grid_w":452,"solar_c":0,"_stats":{"brcv":1699989443.435617,"mrcv":1699989443.552,"msnd":1699989443.552},"aux":{"solar":[-6.2918267250061035]},"power_flow":{"solar":["home"],"grid":["home"]},"solar_pct":1,"d_w":458,"d_solar_w":6,"epoch":1699988873} type=realtime_update 
sense-collector: poll_check=23

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   230    0     0  100   230      0   3432 --:--:-- --:--:-- --:--:--  3432
HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: 706535bb-8322-11ee-b5c1-02420a000302
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.8.0
X-Request-Id: 706535bb-8322-11ee-b5c1-02420a000302
Date: Tue, 14 Nov 2023 19:17:23 GMT
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   246    0     0  100   246      0   3727 --:--:-- --:--:-- --:--:--  3727

and sometimes showing error 400 bad request too:

HTTP/1.1 400 Bad Request
Content-Type: application/json
Request-Id: 7cd1b35c-8324-11ee-87fc-02420a000302
X-Influxdb-Build: OSS
X-Influxdb-Error: partial write: unable to parse 'sense_mains,leg=L2 voltage= 1699989750': missing field value unable to parse 'sense_mains,leg=L2 watts= 1699989750': missing field value dropped=0
X-Influxdb-Version: 1.8.0
X-Request-Id: 7cd1b35c-8324-11ee-87fc-02420a000302
Date: Tue, 14 Nov 2023 19:32:04 GMT
Content-Length: 192
error=partial write: unable to parse 'sense_mains,leg=L2 voltage= 1699989750': missing field value
unable to parse 'sense_mains,leg=L2 watts= 1699989750': missing field value dropped=0 

InfluxDB log also stated the same:

[httpd] 10.0.3.20 - sensedb [14/Nov/2023:19:36:00 +0000] "POST /write?db=sense HTTP/1.1" 204 0 "-" "curl/7.64.0" 0a41db03-8325-11ee-8bea-02420a000302 4578031
[httpd] 10.0.3.20 - sensedb [14/Nov/2023:19:36:00 +0000] "POST /write?db=sense&precision=s HTTP/1.1" 400 192 "-" "curl/7.64.0" 0a41a891-8325-11ee-8be9-02420a000302 4584451
[httpd] 10.0.3.20 - sensedb [14/Nov/2023:19:36:03 +0000] "POST /write?db=sense&precision=s HTTP/1.1" 400 192 "-" "curl/7.64.0" 0c0cdeaf-8325-11ee-8bec-02420a000302 3228334
[httpd] 10.0.3.20 - sensedb [14/Nov/2023:19:36:05 +0000] "POST /write?db=sense HTTP/1.1" 204 0 "-" "curl/7.64.0" 0d0b6a75-8325-11ee-8bee-02420a000302 2477032
[httpd] 10.0.3.20 - sensedb [14/Nov/2023:19:36:05 +0000] "POST /write?db=sense&precision=s HTTP/1.1" 204 0 "-" "curl/7.64.0" 0d0bc8cb-8325-11ee-8bef-02420a000302 2474658

I have also tried to re-authenticate using "./generate_docker-compose.sh" command and use the new token too, unfortunately, still showing the same http 204 result

Is there something that I missed?

Thank you

lux4rd0 commented 2 weeks ago

With a new release today and brand new code, please try if you're still interested! Thanks for hanging in there!