Skip to content
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 the expansion module.. #5

Closed
ThomasADavis opened this issue Jun 4, 2020 · 5 comments
Closed

support for the expansion module.. #5

ThomasADavis opened this issue Jun 4, 2020 · 5 comments

Comments

@ThomasADavis
Copy link

Only the primary metering shows up, the expansion module does not at this time.

@ThomasADavis
Copy link
Author

ThomasADavis commented Jun 4, 2020

hopefully, this would help the first is the vue with expansion, the second is the zigbee meter reader

{
  'deviceGid': 10854,
  'manufacturerDeviceId': '0001240ac495a2f4',
  'model': 'VUE001',
  'firmware': 'Vue-1587661391',
  'outlet': None,
  'devices': [
    {
      'deviceGid': 10854,
      'manufacturerDeviceId': 'SX0001240ac495a2f4',
      'model': 'WAT001',
      'firmware': None,
      'channels': [
        {'deviceGid': 10854, 'name': 'masterbath', 'channelNum': '1', 'channelMultiplier': 1.0, 'channelTypeGid': 18},
        {'deviceGid': 10854, 'name': 'masterfan', 'channelNum': '2', 'channelMultiplier': 1.0, 'channelTypeGid': 18},
        {'deviceGid': 10854, 'name': 'media box', 'channelNum': '3', 'channelMultiplier': 1.0, 'channelTypeGid': 6},
        {'deviceGid': 10854, 'name': 'kitchen GFCI 2', 'channelNum': '4', 'channelMultiplier': 1.0, 'channelTypeGid': 16},
        {'deviceGid': 10854, 'name': 'kitchen GFCI 1', 'channelNum': '5', 'channelMultiplier': 1.0, 'channelTypeGid': 16},
        {'deviceGid': 10854, 'name': 'dishwasher', 'channelNum': '6', 'channelMultiplier': 1.0, 'channelTypeGid': 8},
        {'deviceGid': 10854, 'name': 'fridge', 'channelNum': '7', 'channelMultiplier': 1.0, 'channelTypeGid': 10},
        {'deviceGid': 10854, 'name': 'bedroom', 'channelNum': '8', 'channelMultiplier': 1.0, 'channelTypeGid': 18}
      ]
    }
  ],
  'channels': [
     {'deviceGid': 10854, 'name': None, 'channelNum': '1,2,3', 'channelMultiplier': 1.0, 'channelTypeGid': None}
  ]
}

{
  'deviceGid': 10998, 
  'manufacturerDeviceId': 'Z000246f287e2070', 
  'model': 'ZIG001', 
  'firmware': 'Zigbee-1584707870', 
  'outlet': None, 
  'devices': [], 
  'channels': [
    {'deviceGid': 10998, 'name': None, 'channelNum': '1,2,3', 'channelMultiplier': 1.0, 'channelTypeGid': None}
  ]
} 

@ThomasADavis
Copy link
Author

import json
from pprint import pprint
from pyemvue import PyEmVue
from pyemvue.enums import TotalTimeFrame, TotalUnit

with open('keys.json') as f:
    data = json.load(f)

vue = PyEmVue()

vue.login(id_token=data['idToken'],
    access_token=data['accessToken'],
    refresh_token=data['refreshToken'],
    token_storage_file='keys.json')

d1 = vue.get_devices()[0]

device = vue.populate_device_properties(d1)

for channel in device.channels:
    energy_usage = vue.get_total_usage(channel, timeFrame=TotalTimeFrame.ALL.value, unit=TotalUnit.WATTHOURS.value)
    print(energy_usage)

for d in vue.get_recent_usage():
    print(d.channel_num, d.device_gid, d.usage)

generates this:

299325.2765828418
1,2,3 10854 1028.1919501882294
1 10854 88.4519659123831
2 10854 64.48292660635688
3 10854 175.67066196661855
4 10854 0
5 10854 0
6 10854 0
7 10854 71.17472086588542
8 10854 243.6997487163378
1,2,3 10998 1041.8636325242785

@magico13
Copy link
Owner

magico13 commented Jun 4, 2020

Alright, so it looks like the expansion module gets added as a sub-device to the main one and I was assuming it would be added as extra channels on the main device. I'll have to make a change in PyEmVue to read the sub-devices and their channels as well, then have the home assistant integration look for that data. That seems straightforward enough.

@magico13
Copy link
Owner

magico13 commented Jun 5, 2020

Alright I just pushed a new release that will hopefully set up sensors for the channels in the expansion module. It should pull the right names for each of the channels and for the main device and should update the data correctly but I obviously can't do too much testing of it at the moment. Let me know if it works!

@ThomasADavis
Copy link
Author

it works! All ten channels show up (the meter, the vue, and the 8 expansion CT's..)

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants