magico13 / PyEmVue

Python Library for the Emporia Vue Energy Monitor
MIT License
185 stars 36 forks source link

Any version for Jeedom like ha-emporia-vue ? #34

Open tazelbaze opened 2 years ago

tazelbaze commented 2 years ago

Such a good script for Emporia. Any chance to have it for Jeedom ?

magico13 commented 2 years ago

Home Assistant is the only one I have plans to officially support myself since that's the one I use personally. However if someone decides to create something for another home automation provider I'd be happy to provide guidance and accept pull requests if they need changes in the library.

tazelbaze commented 2 years ago

hummm... thanks for that. i'm too short in programming but i've seen that Jeedom is able to embed py script. Maybe it was possible... For this time i've deployer an HA instance, with MQTT and node-red and send data to Jeedom :-( A crazy thing !

tazelbaze commented 2 years ago

this file works, but I get stuck on generating a json file that is easier to use. I blend in the indentations ... I generate a flat file, but I struggle with a json Any help ?

` from pyemvue import PyEmVue

def print_recursive(usage_dict, info, depth=0): for gid, device in usage_dict.items(): for channelnum, channel in device.channels.items(): name = channel.name if name == 'Main': name = info[gid].device_name print('-'*depth, f'{gid} {channelnum} {name} {channel.usage} kwh') fichier.write(f'{gid} {channelnum} {name} {channel.usage} kwh\n') if channel.nested_devices: print_recursive(channel.nested_devices, depth+1)

vue = PyEmVue() vue.login(username=xxxx@gmail.com', password='xxxxx', token_storage_file='keys.json')

devices = vue.get_devices() device_gids = [] info = {} fichier = open("PyEmVue.log", "w+")

for device in devices: if not device.device_gid in device_gids: device_gids.append(device.device_gid) info[device.device_gid] = device else: info[device.device_gid].channels += device.channels

device_usage_dict = vue.get_device_list_usage(deviceGids=device_gids, instant=None, scale="1MIN", unit="KilowattHours") print_recursive(device_usage_dict, info) fichier.write("\n C'est fini ") fichier.close() `