New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Revolt NC-5461 energy meter #47

Closed
diplix opened this Issue Feb 8, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@diplix

diplix commented Feb 8, 2017

http://www.pearl.de/a-NC5462-5452.shtml

this is what rfxtrx reports:
bildschirmfoto 2017-02-08 um 22 53 45

i guess these are the parameters pyRFXtrx needs to recognise:

  • Instant Power
  • total usage

would of course be nice to also get:

  • Voltage
  • Current
  • Frequency

right now rfxtrx reports the values every 4 seconds, but pyRFXtrx (and home assistant) don’t recognise it.

if i knew how to get the raw output from rfxtrx, i’m glad to provide it.

@diplix diplix changed the title from Support for Revolt NC-5461 to Support for Revolt NC-5461 energy meter Feb 8, 2017

@diplix

This comment has been minimized.

Show comment
Hide comment
@diplix

diplix Feb 9, 2017

https://github.com/rfxcom/node-rfxcom/blob/188e8187e0f321121f29f9ff7753267f56e8335e/lib/rfxcom.js#L1145

/**
 *
 * Called by the data event handler when data arrives from a REVOLT power measurement
 * device (packet type 0x5c).
 *
 */
RfxCom.prototype.elec5Handler = function (data) {
    var self = this;
    var evt;
    evt = {
        subtype: data[0],
        seqnbr: data[1],
        id: "0x" + self.dumpHex(data.slice(2, 4), false).join(""),
        voltage: data[4],
        current: (data[5]*256 + data[6])/100,
        power:  (data[7]*256 + data[8])/10,
        energy:  (data[9]*256 + data[10])*10,  // units watt-hours
        powerFactor: data[11]/100,
        frequency: data[12],
        rssi: (data[13] >> 4) & 0xf
    };
    self.emit("elec5", evt);
};

diplix commented Feb 9, 2017

https://github.com/rfxcom/node-rfxcom/blob/188e8187e0f321121f29f9ff7753267f56e8335e/lib/rfxcom.js#L1145

/**
 *
 * Called by the data event handler when data arrives from a REVOLT power measurement
 * device (packet type 0x5c).
 *
 */
RfxCom.prototype.elec5Handler = function (data) {
    var self = this;
    var evt;
    evt = {
        subtype: data[0],
        seqnbr: data[1],
        id: "0x" + self.dumpHex(data.slice(2, 4), false).join(""),
        voltage: data[4],
        current: (data[5]*256 + data[6])/100,
        power:  (data[7]*256 + data[8])/10,
        energy:  (data[9]*256 + data[10])*10,  // units watt-hours
        powerFactor: data[11]/100,
        frequency: data[12],
        rssi: (data[13] >> 4) & 0xf
    };
    self.emit("elec5", evt);
};

@diplix

This comment has been minimized.

Show comment
Hide comment
@diplix

diplix Feb 9, 2017

this is the raw output that i could receive with receive.py:

Recv: 0x0f 0x5c 0x01 0x00 0x23 0x95 0xbd 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x32 0x80
Recv: 0x0f 0x5c 0x01 0x01 0x23 0x95 0xbc 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x32 0x80
Recv: 0x0f 0x5c 0x01 0x02 0x23 0x95 0xbd 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x32 0x80
Recv: 0x0f 0x5c 0x01 0x03 0x23 0x95 0xbd 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x32 0x80
Recv: 0x0f 0x5c 0x01 0x04 0x23 0x95 0xbd 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x32 0x80
Recv: 0x0f 0x5c 0x01 0x05 0x23 0x95 0xbd 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x32 0x80

diplix commented Feb 9, 2017

this is the raw output that i could receive with receive.py:

Recv: 0x0f 0x5c 0x01 0x00 0x23 0x95 0xbd 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x32 0x80
Recv: 0x0f 0x5c 0x01 0x01 0x23 0x95 0xbc 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x32 0x80
Recv: 0x0f 0x5c 0x01 0x02 0x23 0x95 0xbd 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x32 0x80
Recv: 0x0f 0x5c 0x01 0x03 0x23 0x95 0xbd 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x32 0x80
Recv: 0x0f 0x5c 0x01 0x04 0x23 0x95 0xbd 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x32 0x80
Recv: 0x0f 0x5c 0x01 0x05 0x23 0x95 0xbd 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x32 0x80
@Danielhiversen

This comment has been minimized.

Show comment
Hide comment
@Danielhiversen

Danielhiversen Feb 9, 2017

Owner

Hey.
To add support for your device, you have to make a new class in the lowlevel.py file.
A good start would be to duplicate the this class
https://github.com/Danielhiversen/pyRFXtrx/blob/master/RFXtrx/lowlevel.py#L1755
And then modify the protocol to match the one you have found.

Then you have to add

    elif data[1] == 0x5c:
        pkt =  Energy5()

here https://github.com/Danielhiversen/pyRFXtrx/blob/master/RFXtrx/lowlevel.py#L41.

Owner

Danielhiversen commented Feb 9, 2017

Hey.
To add support for your device, you have to make a new class in the lowlevel.py file.
A good start would be to duplicate the this class
https://github.com/Danielhiversen/pyRFXtrx/blob/master/RFXtrx/lowlevel.py#L1755
And then modify the protocol to match the one you have found.

Then you have to add

    elif data[1] == 0x5c:
        pkt =  Energy5()

here https://github.com/Danielhiversen/pyRFXtrx/blob/master/RFXtrx/lowlevel.py#L41.

@diplix

This comment has been minimized.

Show comment
Hide comment
@diplix

diplix Feb 9, 2017

tnx. figured that out after studying the code and almost done, too. problem is: i’m a lousy programmer, there’s still something buggy. i’ll keep trying.

diplix commented Feb 9, 2017

tnx. figured that out after studying the code and almost done, too. problem is: i’m a lousy programmer, there’s still something buggy. i’ll keep trying.

@Danielhiversen

This comment has been minimized.

Show comment
Hide comment
@Danielhiversen

Danielhiversen Feb 9, 2017

Owner

You can open a pull request with you wip code.
Then it will be easier for people to comment and help.

Owner

Danielhiversen commented Feb 9, 2017

You can open a pull request with you wip code.
Then it will be easier for people to comment and help.

diplix added a commit to diplix/pyRFXtrx that referenced this issue Feb 9, 2017

added ELEC5 paket type
regarding: #47

unfortunatly the addidion doesn’t work, though i think it should. can’t find the error, but i get this in the home assistant logs:

``` 
  File "/Users/ix/.homeassistant/deps/RFXtrx/__init__.py", line 693, in _connect
  File "/Users/ix/.homeassistant/deps/RFXtrx/__init__.py", line 606, in receive_blocking
  File "/Users/ix/.homeassistant/deps/RFXtrx/__init__.py", line 550, in parse
  File "/Users/ix/.homeassistant/deps/RFXtrx/__init__.py", line 418, in __init__
  File "/Users/ix/.homeassistant/deps/RFXtrx/lowlevel.py", line 134, in __getattr__
 ```
also added this in __init__.py row 410:
```
        if isinstance(pkt, lowlevel.Energy5):
            self.values['Energy usage'] = pkt.currentwatt
            self.values['Total usage'] = pkt.totalwatthours
```

Danielhiversen added a commit that referenced this issue Feb 11, 2017

Added ELEC5 paket type (#48)
* added ELEC5 paket type

regarding: #47

unfortunatly the addidion doesn’t work, though i think it should. can’t find the error, but i get this in the home assistant logs:

``` 
  File "/Users/ix/.homeassistant/deps/RFXtrx/__init__.py", line 693, in _connect
  File "/Users/ix/.homeassistant/deps/RFXtrx/__init__.py", line 606, in receive_blocking
  File "/Users/ix/.homeassistant/deps/RFXtrx/__init__.py", line 550, in parse
  File "/Users/ix/.homeassistant/deps/RFXtrx/__init__.py", line 418, in __init__
  File "/Users/ix/.homeassistant/deps/RFXtrx/lowlevel.py", line 134, in __getattr__
 ```
also added this in __init__.py row 410:
```
        if isinstance(pkt, lowlevel.Energy5):
            self.values['Energy usage'] = pkt.currentwatt
            self.values['Total usage'] = pkt.totalwatthours
```

* added battery

with that he battery attribute i got rid of the errors and it basically works now.

* add attributes for energy5

* remove battery for revolt meter

* remove battery for revolt meter

* initial try to test Elec5

* correct voltage

* another try to get the right values

* this should fix the tests

* remove trailing whitespace

* fix blank lines and long lines

* fix redundant backslash

* fix trailing whitespace

* use actual packet and values for testing

@diplix diplix closed this Feb 12, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment