aviborg / esp-smart-meter

A reliable ESP8266 application to read out data from (swedish) COSEM/DLMS based smart meters using OBIS code/structure.
Apache License 2.0
46 stars 6 forks source link

payload values scrambled #3

Closed petterl closed 3 years ago

petterl commented 3 years ago

I setup the emeter but dont get the correct data as the examples. There could be hw issues and error in connections, but I get data to data.json

{"elapsedtime":390288,"rssi":-75,"mac":"48:3F:DA:01:31:1E","localip":"192.168.1.200","ssid":"petter@sandholdt.se","header":{"encoding":"A-XDR","frameformat":3,"segmentation":0,"datalength":579,"client":65,"server":2179,"control":19,"hcs":"eb85","fcs":"cb30","llc":"e6e700"},"apdu":{"tag":15,"liiap":"40000000","datetime":"00"},"payload":{"0000010000FF":["07E502140615050AFF8000FF"],"0100010700FF":[1136,[0,"W"]],"0100020700FF":[0,[0,"W"]],"0100030700FF":[0,[0,"var"]],"0100040700FF":[685,[0,"var"]],"01001F0700FF":[21,[-1,"A"]],"0100330700FF":[18,[-1,"A"]],"0100470700FF":[18,[-1,"A"]],"0100200700FF":[2298,[-1,"V"]],"0100340700FF":[2300,[-1,"V"]],"0100480700FF":[2316,[-1,"V"]],"0100150700FF":[472,[0,"W"]],"0100160700FF":[0,[0,"W"]],"0100170700FF":[0,[0,"var"]],"0100180700FF":[127,[0,"var"]],"0100290700FF":[277,[0,"W"]],"01002A0700FF":[0,[0,"W"]],"01002B0700FF":[0,[0,"var"]],"01002C0700FF":[323,[0,"var"]],"01003D0700FF":[372,[0,"W"]],"01003E0700FF":[0,[0,"W"]],"01003F0700FF":[0,[0,"var"]],"0100400700FF":[214,[0,"var"]],"0100010800FF":[3344019,[0,"Wh"]],"0100020800FF":[0,[0,"Wh"]],"0100030800FF":[77281,[0,"varh"]],"0100040800FF":[639546,[0,"varh"]]}}

and log.txt:


--- Start ---
0x02, 0x0f, 0000, 0x16, 0x1d, 0x02, 0x03, 0x09, 0x06, 0x01, 0000, 0x29, 0x07, 0000, 0xff, 0x06, 
0000, 0000, 0x01, 0x1c, 0x02, 0x02, 0x0f, 0000, 0x16, 0x1b, 0x02, 0x03, 0x09, 0x06, 0x01, 0000, 
0x2a, 0x07, 0000, 0xff, 0x06, 0000, 0000, 0000, 0000, 0x02, 0x02, 0x0f, 0000, 0x16, 0x1b, 0x02, 
0x03, 0x09, 0x06, 0x01, 0000, 0x2b, 0x07, 0000, 0xff, 0x06, 0000, 0000, 0000, 0000, 0x02, 0x02, 
0x0f, 0000, 0x16, 0x1d, 0x02, 0x03, 0x09, 0x06, 0x01, 0000, 0x2c, 0x07, 0000, 0xff, 0x06, 0000, 
0000, 0x01, 0x4a, 0x02, 0x02, 0x0f, 0000, 0x16, 0x1d, 0x02, 0x03, 0x09, 0x06, 0x01, 0000, 0x3d, 
0x07, 0000, 0xff, 0x06, 0000, 0000, 0x01, 0xb4, 0x02, 0x02, 0x0f, 0000, 0x16, 0x1b, 0x02, 0x03, 
0x09, 0x06, 0x01, 0000, 0x3e, 0x07, 0000, 0xff, 0x06, 0000, 0000, 0000, 0000, 0x02, 0x02, 0x0f, 
0000, 0x16, 0x1b, 0x02, 0x03, 0x09, 0x06, 0x01, 0000, 0x3f, 0x07, 0000, 0xff, 0x06, 0000, 0000, 
0000, 0x8f, 0x02, 0x02, 0x0f, 0000, 0x16, 0x1d, 0x02, 0x03, 0x09, 0x06, 0x01, 0000, 0x40, 0x07, 
0000, 0xff, 0x06, 0000, 0000, 0000, 0000, 0x02, 0x02, 0x0f, 0000, 0x16, 0x1d, 0x02, 0x03, 0x09, 
0x06, 0x01, 0000, 0x01, 0x08, 0000, 0xff, 0x06, 0000, 0x33, 0x06, 0x19, 0x02, 0x02, 0x0f, 0000, 
0x16, 0x1e, 0x02, 0x03, 0x09, 0x06, 0x01, 0000, 0x02, 0x08, 0000, 0xff, 0x06, 0000, 0000, 0000, 
0000, 0x02, 0x02, 0x0f, 0000, 0x16, 0x1e, 0x02, 0x03, 0x09, 0x06, 0x01, 0000, 0x03, 0x08, 0000, 
0xff, 0x06, 0000, 0x01, 0x2d, 0xe1, 0x02, 0x02, 0x0f, 0000, 0x16, 0x20, 0x02, 0x03, 0x09, 0x06, 
0x01, 0000, 0x04, 0x08, 0000, 0xff, 0x06, 0000, 0x09, 0xc2, 0x19, 0x02, 0x02, 0x0f, 0000, 0x16, 
0x20, 0x48, 0x0f, 0x7e, 
---  End  ---
aviborg commented 3 years ago

The data.json is correct. Looks like the Aidon meter. Which application do you use to read the json data?

aviborg commented 3 years ago

Dont worry about the log.txt, it looks it was filled during startup.

petterl commented 3 years ago

Yes its an aidon meter from tekniska verken. I was planning to Use it in HASS. How to I setup the sensors for this?

aviborg commented 3 years ago

For Home Assistant, try using this in your configuration.yaml:

sensor:
  - platform: rest
    resource: http://emeter.local/data.json
    name: electricity_meter
    scan_interval: 10
    value_template: 'OK'
    json_attributes:
      - payload
  - platform: template
    sensors:
      p1_current:
        friendly_name: 'P1 Current'
        value_template: '{{ states.sensor.electricity_meter.attributes["payload"]["01001F0700FF"][0] | float/10 }}'
      p2_current:
        friendly_name: 'P2 Current'
        value_template: '{{ states.sensor.electricity_meter.attributes["payload"]["0100330700FF"][0] | float/10 }}'
      p3_current:
        friendly_name: 'P3 Current'
        value_template: '{{ states.sensor.electricity_meter.attributes["payload"]["0100470700FF"][0] | float/10 }}'