seanauff / metermon

Dockerized rtlamr wrapper that outputs formatted JSON messages over mqtt
MIT License
66 stars 12 forks source link

I don't see my Gas, Electric or Water ID's #31

Closed wptracy closed 1 year ago

wptracy commented 1 year ago

I live in Denver Colorado and I see lots of Gas, Water, and Electric reading with this app, but my meter numbers are never displayed/detected.

seanauff commented 1 year ago

I am also in Denver metro and we just got the new Xcel smart meter which doesn't work with this method. Is that the case for you?

wptracy commented 1 year ago

Yes, I have the new smart meter, and I'm trialing Xcel Energy's new "My Energy Connection" app for iphone and android.

It measures live, real time usage in watts. Xcel told me they will release the app for everyone in May. Xcel Energy also told me it would work on home assistant. He might have misunderstood my question when I asked him if it would work on home assistant.

I wonder what electric company is broadcasting all the Electric Meter readings. I get lots of readings.

Excel told me they were going to drive thru my neighborhood on Friday to get my Gas meter reading.

Are you getting your gas meter reading? Do you get it hourly, daily, or monthly?

Do you get your water meter reading?

I don't get my water, or gas meter readings. I can understand why Electric stopped with the new xcel smart meter.

But you would think I would get gas and water readings.

seanauff commented 1 year ago

Some of us have got the new meter working with home assistant (described here). I also post my hass config on my github profile so check there as I made some tweaks from the thread.

Gas meter is very intermittent, once a month if I'm lucky. It's a 20 year old meter, so perhaps its only broadcasts on a wakeup signal from the meter reading truck in order to conserve power. My previous house had a brand new gas meter that broadcast every few minutes.

Water meter isn't compatible with rtlamr (at least I haven't looked into it in awhile).

So unfortunately for me, my metermon project isn't too useful anymore! Though the new smart electric meter (once I got over the hump of talking to it) it a huge improvement in sampling frequency over the old method. Will be neat to see it really shine once our grid-tied solar install is complete.

wptracy commented 1 year ago

Thanks Sean.

I read the posts on the forum and created certificates and LFDI per pdubs10 post. https://community.home-assistant.io/t/xcel-energy-itron-gen-5-riva/346943/57

I enrolled in Xcel Energy Launchpad and added a device at https://my.xcelenergy.com/MyAccount/s/meters-and-devices/manage-meters-and-devices.

I added your xcelmeter.yaml and restarted.

I don't believe it but I'm seeing readings on the sensors you created. I thought it would take a week for LFDI registration. [core-ssh xcelcerts]$ ls -l total 12 -rw-r--r-- 1 root root 1834 Feb 10 07:13 cert.pem -rw-r--r-- 1 root root 3272 Feb 10 07:13 key.pem -rw-r--r-- 1 root root 3825 Feb 10 07:39 opensslKeys [core-ssh xcelcerts]$ curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/3/r --cert /config/xcelcerts/cert.pem --key /root/xcelcerts/key.pem curl: (58) could not load PEM client certificate, OpenSSL error error:02001002:system library:fopen:No such file or directory, (no key found, wrong pass phrase, or wrong file format?) [core-ssh xcelcerts]$ pwd /root/xcelcerts [core-ssh xcelcerts]$

I knew it was too good to be true. I'm monitoring the Smart Energy Switch, not the Smart Electric Meter Consumption.

I added Smart Energy Switch Electric Consumption [kWh] to my Electricity grid on Energy. I hope it updates with my Smart Meter readings.

state = 0.42 state_class: measurement meter_type: 1 meter_type_name: ELECTRIC unit_of_measurement: W device_class: power friendly_name: Smart Energy Switch Electric Consumption [W]

state = 2.09 state_class: total_increasing meter_type: 1 meter_type_name: ELECTRIC unit_of_measurement: kWh device_class: energy friendly_name: Smart Energy Switch Electric Consumption [kWh]

My iPhone app to monitor current watts says 2224w, but Developer tools says .42w. The math is wrong.

IMG_9892 Screenshot from 2023-02-10 10-21-13 Screenshot from 2023-02-10 10-26-40 Screenshot from 2023-02-10 10-50-11

seanauff commented 1 year ago

The cURL/SSL error you are getting looks to be an issue with the location of those certs you created. I put them in the /config/xcelcerts/ directory, just make sure you know where they're in your hass config folder and that the cURL commands points to that correctly.

wptracy commented 1 year ago

You're right. I did forget to change config to root in all places. [core-ssh ~]$ curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/3/r --cert /root/xcelcerts/cert.pem --key /root/xcelcerts/key.pem [core-ssh ~]$

I'm getting a 404 not found from this curl. I hope it's because xcel hasn't registered my LFDI. Do you think that's the case?

[core-ssh ~]$ curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure -v --url https://10.0.0.226:8081/upt --cert /root/xcelcerts/cert.pem --key /root/xcelcerts/key.pem
*   Trying 10.0.0.226:8081...
* Connected to 10.0.0.226 (10.0.0.226) port 8081 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
* Cipher selection: ECDHE-ECDSA-AES128-CCM8
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Request CERT (13):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-AES128-CCM8
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
*  subject: [NONE]
*  start date: Feb  8 18:46:17 2022 GMT
*  expire date: Dec 31 23:59:00 9999 GMT
*  issuer: C=US; O=Itron; CN=IEEE 2030.5 MICA; serialNumber=7
*  SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
> GET /upt HTTP/1.1
> Host: 10.0.0.226:8081
> User-Agent: curl/7.83.1
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Date: Fri, 10 Feb 2023 19:40:53 GMT
< Content-Length: 0
< 
* Connection #0 to host 10.0.0.226 left intact
[core-ssh ~]$ 
seanauff commented 1 year ago

Did you create your own certs or use the example ones show in this post? I just used the examples from that post (along with the LFDI).

wptracy commented 1 year ago

I applied for both certs, my own and the one on the forum. I used pdubs10's method to create my certs and LFDI.

I have LFDI 58F371CB4CF0FC393B459559576904D1F7E338EE certs in /root/config/xcelcerts. I was sort of shocked that someone published their certs.

I have my LFDI certs in /root/xcelcerts.

I did both in case xcel rejects LFDI 58F371CB4CF0FC393B459559576904D1F7E338EE because it's already in use, and I want to better understand certs and how they work.

If my certs don't work, his might.

I also thought I should be using my own certs, not someone else's.

Oh but look, there is a difference. When I use his certs I get more information. I have both below. Maybe his LFDI is working on my meter. I'll try it.

Yes!! His LFDI works on my meter.

[core-ssh xcelcerts]$ curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/3/r --cert /root/config/xcelcerts/cert.pem --key /root/config/xcelcerts/key.pem 2>&1 | grep -o '.' | grep -Eo '[0-9]+' 10701110 [core-ssh xcelcerts]$ [core-ssh xcelcerts]$ curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/3/r --cert /root/config/xcelcerts/cert.pem --key /root/config/xcelcerts/key.pem 2>&1 | grep -o '.' | grep -Eo '[0-9]+' 10701545 [core-ssh xcelcerts]$ curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/3/r --cert /root/config/xcelcerts/cert.pem --key /root/config/xcelcerts/key.pem 2>&1 | grep -o '.' | grep -Eo '[0-9]+' 10701546 [core-ssh xcelcerts]$ curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/1/r --cert /root/config/xcelcerts/cert.pem --key /root/config/xcelcerts/key.pem 2>&1 | grep -o '.' | grep -Eo '[0-9]+' 1717 [core-ssh xcelcerts]$ curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/1/r --cert /root/config/xcelcerts/cert.pem --key /root/config/xcelcerts/key.pem 2>&1 | grep -o '.*' | grep -Eo '[0-9]+' 1722

Watts and kWh's both work!!!

I restarted and found no sensor entities for this. How do platform: command_line s get called. Or do they start up by themselves. Should I see sensors?

[core-ssh xcelcerts]$ curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure -v --url https://10.0.0.226:8081/upt --cert /root/config/xcelcerts/cert.pem --key /root/config/xcelcerts/key.pem
*   Trying 10.0.0.226:8081...
* Connected to 10.0.0.226 (10.0.0.226) port 8081 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
* Cipher selection: ECDHE-ECDSA-AES128-CCM8
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Request CERT (13):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS handshake, CERT verify (15):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-AES128-CCM8
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
*  subject: [NONE]
*  start date: Feb  8 18:46:17 2022 GMT
*  expire date: Dec 31 23:59:00 9999 GMT
*  issuer: C=US; O=Itron; CN=IEEE 2030.5 MICA; serialNumber=7
*  SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
> GET /upt HTTP/1.1
> Host: 10.0.0.226:8081
> User-Agent: curl/7.83.1
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Fri, 10 Feb 2023 21:46:53 GMT
< Content-Length: 545
< Content-Type: application/sep+xml
< 
<UsagePointList
     xmlns="urn:ieee:std:2030.5:ns"
     href="/upt"
     subscribable="0"
     all="1"
     results="1"
     pollRate="900">

    <UsagePoint
         href="/upt/1">
        <mRID>AAAA01000000000000000000000004D1</mRID>
        <description>Meter Usage Point</description>
        <roleFlags>00</roleFlags>
        <serviceCategoryKind>0</serviceCategoryKind>
        <status>1</status>
        <MeterReadingListLink
             href="/upt/1/mr"
             all="3"/>
    </UsagePoint>

</UsagePointList>
* Connection #0 to host 10.0.0.226 left intact
[core-ssh xcelcerts]$ 
[core-ssh xcelcerts]$ 
[core-ssh xcelcerts]$ curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure -v --url https://10.0.0.226:8081/upt --cert /root/xcelcerts/cert.pem --key /root/xcelcerts/key.pem
*   Trying 10.0.0.226:8081...
* Connected to 10.0.0.226 (10.0.0.226) port 8081 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
* Cipher selection: ECDHE-ECDSA-AES128-CCM8
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Request CERT (13):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-AES128-CCM8
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
*  subject: [NONE]
*  start date: Feb  8 18:46:17 2022 GMT
*  expire date: Dec 31 23:59:00 9999 GMT
*  issuer: C=US; O=Itron; CN=IEEE 2030.5 MICA; serialNumber=7
*  SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
> GET /upt HTTP/1.1
> Host: 10.0.0.226:8081
> User-Agent: curl/7.83.1
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Date: Fri, 10 Feb 2023 21:47:55 GMT
< Content-Length: 0
< 
* Connection #0 to host 10.0.0.226 left intact
[core-ssh xcelcerts]$ 
seanauff commented 1 year ago

The certs on the forum are just the example ones from the Xcel SDK.

The command line sensors should create entities. Did you specify to include the xcelmeter yaml file in your configuration yaml file?

wptracy commented 1 year ago

It sounds like I missed a step. Should I backup and submit a Software Development Kit Access Request Form?

I tried pointing sensor to xcelmeter.yaml by entering this in configuration.yaml. "sensor: !include xcelmeter.yaml" but "check configuration" complained. So I gave up trying to make that work and copied two command_line's into configurations.yaml.

sensor:
  - platform: command_line
    name: "Smart Electric Meter Power"
    command: "/usr/bin/curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/1/r --cert /root/config/xcelcerts/cert.pem --key /root/config/xcelcerts/key.pem 2>&1 | grep -o '<value>.*</value>' | grep -Eo '[0-9]+'"
    unit_of_measurement: "W"
    #device_class: 'power'
    scan_interval: 5
    command_timeout: 5

  - platform: command_line
    name: "Smart Electric Meter Consumption"
    command: "/usr/bin/curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/3/r --cert /root/config/xcelcerts/cert.pem --key /root/config/xcelcerts/key.pem 2>&1 | grep -o '<value>.*</value>' | grep -Eo '[0-9]+'"
    unit_of_measurement: "kWh"
    value_template: "{{ value | multiply(0.001) | round(3)}}"
    #device_class: 'energy'
    #state_class: 'total_increasing'
    scan_interval: 5
    command_timeout: 5

homeassistant:
  customize:
    sensor.smart_electric_meter_consumption:
      device_class: energy
      state_class: "total_increasing"

    sensor.smart_electric_meter_power:
      device_class: power

Now I have entities, but no sensors because the curl command fails.

If I ssh into home assistant to execute these commands I get watts and kWh.

[core-ssh ~]$ curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/1/r --cert /root/config/xcelcerts/cert.pem --key /root/config/xcelcerts/key.pem 2>&1 | grep -o '<value>.*</value>'  2>&1 | grep -o '<value>.*</value>' | grep -Eo '[0-9]+'
863
[core-ssh ~]$ curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/3/r --cert /root/config/xcelcerts/cert.pem --key /root/config/xcelcerts/key.pem 2>&1 | grep -o '<value>.*</value>' | grep -Eo '[0-9]+'
10722340
[core-ssh ~]$ 

When home assistant restarts I get this error: Home assistant can't execute the curl command, so the entities never get updated with sensor data.

Logger: homeassistant.components.command_line
Source: components/command_line/__init__.py:48
Integration: command_line (documentation, issues)
First occurred: 12:32:33 PM (12 occurrences)
Last logged: 12:33:11 PM

Command failed (with return code 1): /usr/bin/curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/1/r --cert /root/config/xcelcerts/cert.pem --key /root/config/xcelcerts/key.pem 2>&1 | grep -o '<value>.*</value>' | grep -Eo '[0-9]+'
Command failed (with return code 1): /usr/bin/curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/3/r --cert /root/config/xcelcerts/cert.pem --key /root/config/xcelcerts/key.pem 2>&1 | grep -o '<value>.*</value>' | grep -Eo '[0-9]+'

I also replaced the curl command with "ls /dev/ssl" and it failed with return code 1 also. So it's not the curl command or the grep command.

2023-02-12 09:46:33.244 ERROR (SyncWorker_1) [homeassistant.components.command_line] Command failed (with return code 1): ls /root/ssl

UPDATE 16:01

seasideCT at https://community.home-assistant.io/t/xcel-energy-itron-gen-5-riva/346943/83 told me what was wrong. He said remove /root, and that fixed it. Now I have sensors that work.

seanauff commented 1 year ago

Amazing, glad you got it figured out!