I also see to add maker api access token and maker api id. Sorry to bother but I have make api installed can you give me some basic instructions what to do there?
You have to allow access via remote or cloud. The url changes based on your selection. I just use local.
You then select the devices you want to expose (your emporia device in this case) and generate the access token. You can get the base url from the bottom of the page.
Im still confused about where to get the maker api id? some help this would be greatly appreciated is this a url? sorry to be a bother I just want to get this to work.
and also where exactly is the maker api access token?
Scroll to the bottom of the Maker API app and look for access_token=
I got the Auth token to successfully get populated from a synology docker instance via the maker api. But when I click "get device GID" and then "refresh", the child devices are not created. I have two emporia vues on my account (one for the main panel and another for the subpanel) and one emporia EV charger (EVSE). If I uninstall the emporia car charger in the emporia app, then when I click get device GID and refresh, all the child circuits are created and everything seems to work as intended. Could the JSON parsing in this device driver be improved to ignore the charger instead of having to remove it and add it back? Here is the log including the JSON data:
dev:23952024-01-15 12:43:07.069 PMinfodevice Gid not found. Please run the command to Get Device Gid
dev:23952024-01-15 12:43:07.041 PMerrorjava.lang.NullPointerException: Cannot get property 'channels' on null object on line 84 (method getDeviceGid)
dev:23952024-01-15 12:43:07.035 PMdebug287948
dev:23952024-01-15 12:43:07.034 PMdebug287937
dev:23952024-01-15 12:43:06.536 PMdebug[{"battery":null,"channels":[{"channelMultiplier":1.0,"channelNum":"1,2,3","channelTypeGid":null,"deviceGid":287937,"name":null}],"deviceConnected":{"connected":true,"deviceGid":287937,"offlineSince":null},"deviceGid":287937,"devices":[{"channels":[{"channelMultiplier":1.0,"channelNum":"1","channelTypeGid":1,"deviceGid":287937,"name":"minisplit"},{"channelMultiplier":1.0,"channelNum":"2","channelTypeGid":21,"deviceGid":287937,"name":"Sub panel, phase 1"},{"channelMultiplier":1.0,"channelNum":"3","channelTypeGid":21,"deviceGid":287937,"name":"Sub panel, phase 2"},{"channelMultiplier":2.0,"channelNum":"4","channelTypeGid":9,"deviceGid":287937,"name":"emporia EVSE"},{"channelMultiplier":1.0,"channelNum":"5","channelTypeGid":18,"deviceGid":287937,"name":"Fish panel, GFCI"},{"channelMultiplier":1.0,"channelNum":"6","channelTypeGid":12,"deviceGid":287937,"name":"shed"},{"channelMultiplier":1.0,"channelNum":"7","channelTypeGid":18,"deviceGid":287937,"name":"Fish UPS"},{"channelMultiplier":1.0,"channelNum":"8","channelTypeGid":10,"deviceGid":287937,"name":"Utility Room fridge and Air exchangers"},{"channelMultiplier":1.0,"channelNum":"9","channelTypeGid":20,"deviceGid":287937,"name":"Kitchen outlets"},{"channelMultiplier":1.0,"channelNum":"10","channelTypeGid":20,"deviceGid":287937,"name":"Kitchen TV, disposal, washer"},{"channelMultiplier":1.0,"channelNum":"11","channelTypeGid":20,"deviceGid":287937,"name":"Master bedroom"},{"channelMultiplier":1.0,"channelNum":"12","channelTypeGid":20,"deviceGid":287937,"name":"Den 3 circuits"},{"channelMultiplier":2.0,"channelNum":"13","channelTypeGid":19,"deviceGid":287937,"name":"Well pump"},{"channelMultiplier":1.0,"channelNum":"14","channelTypeGid":20,"deviceGid":287937,"name":"kids bedroom"},{"channelMultiplier":2.0,"channelNum":"15","channelTypeGid":7,"deviceGid":287937,"name":"oven"},{"channelMultiplier":1.0,"channelNum":"16","channelTypeGid":20,"deviceGid":287937,"name":"Living room office"}],"deviceGid":287937,"firmware":null,"manufacturerDeviceId":"SXA2328A05B5EC6260EDB6A0","model":"WAT001"}],"evCharger":null,"firmware":"Vue2-434","locationProperties":{"billingCycleStartDay":28,"deviceGid":287937,"deviceName":"main panel","latitudeLongitude":{"latitude":41.762367460110255,"longitude":-71.33479927245935},"locationInformation":{"airConditioning":"true","heatSource":"airSourceHeatPump","locationSqFt":"1800","numElectricCars":"1","numPeople":"3"},"peakDemandDollarPerKw":null,"timeZone":"America/New_York","usageCentPerKwHour":30.34,"utilityRateGid":null,"zipCode":null},"manufacturerDeviceId":"A2328A05B5EC6260EDB6A0","model":"VUE002","outlet":null,"parentChannelNum":null,"parentDeviceGid":null},{"battery":null,"channels":[{"channelMultiplier":1.0,"channelNum":"1,2,3","channelTypeGid":25,"deviceGid":287948,"name":null}],"deviceConnected":{"connected":true,"deviceGid":287948,"offlineSince":null},"deviceGid":287948,"devices":[],"evCharger":{"breakerPIN":"9264","chargerOn":true,"chargingRate":20,"debugCode":"011","deviceGid":287948,"faultText":null,"hideChargeRateSliderText":"Charge Rate is controlled by Load Management","icon":"CarNotConnected","iconDetailText":"Charger will start charging when connected to a vehicle.","iconLabel":"Ready","loadGid":170049,"loadManagementEnabled":true,"maxChargingRate":48,"message":"Ready","proControlCode":null,"status":"Standby"},"firmware":"EVCharger-467","locationProperties":{"billingCycleStartDay":28,"deviceGid":287948,"deviceName":"Ioniq6","latitudeLongitude":{"latitude":41.762367493279584,"longitude":-71.33480182164907},"locationInformation":{"primaryVehicle":"ioniq6"},"peakDemandDollarPerKw":null,"timeZone":"America/New_York","usageCentPerKwHour":30.34,"utilityRateGid":null,"zipCode":null},"manufacturerDeviceId":"D2316A0007EC6260EDC40C","model":"VVDN01","outlet":null,"parentChannelNum":null,"parentDeviceGid":null},{"battery":null,"channels":[{"channelMultiplier":1.0,"channelNum":"1,2,3","channelTypeGid":null,"deviceGid":295676,"name":null}],"deviceConnected":{"connected":true,"deviceGid":295676,"offlineSince":null},"deviceGid":295676,"devices":[{"channels":[{"channelMultiplier":1.0,"channelNum":"1","channelTypeGid":22,"deviceGid":295676,"name":"water heater"},{"channelMultiplier":1.0,"channelNum":"2","channelTypeGid":1,"deviceGid":295676,"name":"Utility room window, AC"},{"channelMultiplier":1.0,"channelNum":"3","channelTypeGid":9,"deviceGid":295676,"name":"EVSE portable"},{"channelMultiplier":1.0,"channelNum":"4","channelTypeGid":19,"deviceGid":295676,"name":"Condensate pump, Ring Alarm, Atlas chargers"},{"channelMultiplier":1.0,"channelNum":"5","channelTypeGid":null,"deviceGid":295676,"name":null},{"channelMultiplier":1.0,"channelNum":"6","channelTypeGid":null,"deviceGid":295676,"name":null},{"channelMultiplier":1.0,"channelNum":"7","channelTypeGid":null,"deviceGid":295676,"name":null},{"channelMultiplier":1.0,"channelNum":"8","channelTypeGid":null,"deviceGid":295676,"name":null},{"channelMultiplier":1.0,"channelNum":"9","channelTypeGid":null,"deviceGid":295676,"name":null},{"channelMultiplier":1.0,"channelNum":"10","channelTypeGid":null,"deviceGid":295676,"name":null},{"channelMultiplier":1.0,"channelNum":"11","channelTypeGid":null,"deviceGid":295676,"name":null},{"channelMultiplier":1.0,"channelNum":"12","channelTypeGid":null,"deviceGid":295676,"name":null},{"channelMultiplier":1.0,"channelNum":"13","channelTypeGid":null,"deviceGid":295676,"name":null},{"channelMultiplier":1.0,"channelNum":"14","channelTypeGid":null,"deviceGid":295676,"name":null},{"channelMultiplier":1.0,"channelNum":"15","channelTypeGid":null,"deviceGid":295676,"name":null},{"channelMultiplier":1.0,"channelNum":"16","channelTypeGid":null,"deviceGid":295676,"name":null}],"deviceGid":295676,"firmware":null,"manufacturerDeviceId":"SXA2322A05B5B8D61A9E7924","model":"WAT001"}],"evCharger":null,"firmware":"Vue2-434","locationProperties":{"billingCycleStartDay":1,"deviceGid":295676,"deviceName":"subpanel","latitudeLongitude":{"latitude":41.76237092220949,"longitude":-71.33480708069177},"locationInformation":null,"peakDemandDollarPerKw":null,"timeZone":"America/New_York","usageCentPerKwHour":13.2,"utilityRateGid":null,"zipCode":null},"manufacturerDeviceId":"A2322A05B5B8D61A9E7924","model":"VUE002","outlet":null,"parentChannelNum":null,"parentDeviceGid":null}]
I don't have an EV Charger so I am not in a position to test anything. I think the problem is that the EV device name is equal to null, and no other channels a present under that device ID. The driver specifically removes null devices.
You could add a statement around lines 80-87 to check for if(value.evCharger == null){ }
. This should exclude the ev device.
Ok I'm working this through, and I'll try to document the steps as I go.
I have the driver installed and the access token sent via the Maker API.
Found a bug, with my Vue 3 monitor
channels = value.devices[0].channels
needs to be
channels = value.devices.channels
Wondering if anyone has setup the token generator on a Pi? I’ve started working with some friends on getting this in place, but since we are far from being experts on the Pi, I’m afraid we aren’t there yet…
We also tried the docker, but unfortunately it isn’t working on the Pi yet… working to see if we can modify it.
UPDATE: we got it running on the Pi by changing some of the docker commands to use the script’s commands. There is likely some issue with the syntax in the update_creds file in the docker when running it on the Pi.
Once the authentication issue got resolved, I noticed the following error, and the child devices were not populating, but did fix that:
To fix it, I updated line 84 like @john18 did above (removed the [0]).
The only issue that remains at this point is that child devices of the main emporia are not populating. This includes the plugs as well as the devices that are under my sub panel (I have 2 Vue 2’s). I wonder if it might be related to the following error:
@ke7lvb, is there any other information that I could provide to help debug this?
UPDATE: ChatGPT suggested I add the following to the bottom of the app code and it seems to have eliminated that last error, though I am still not getting child devices:
// Add this before your metadata section or within the installed() method.
this.metaClass.invokeMethod = { String name, args ->
if (name == "componentRefresh" && args.length == 1) {
refresh()
} else {
def method = this.metaClass.getMetaMethod(name, args)
if (method != null) {
method.invoke(this, args)
} else {
if (logEnable) log.warn "No such method: $name with arguments: $args"
}
}
}
def fetchChild(name){
String thisId = device.id
def cd = getChildDevice(name)
if (!cd) {
cd = addChildDevice("hubitat", "Generic Component Power Meter", name, [name: name, isComponent: false])
}
return cd
}
// Keep the original componentRefresh method if it's still there, or remove it if unnecessary
def componentRefresh(cd) {
refresh()
}
In case it helps, this is the JSON
- JSON : {"deviceListUsages":{"devices":[{"channelUsages":[{"channelNum":"1,2,3","deviceGid":183930,"name":"Main","nestedDevices":[{"channelUsages":[{"channelNum":"1,2,3","deviceGid":186656,"name":"Main","nestedDevices":[{"channelUsages":[{"channelNum":"1,2,3","deviceGid":189565,"name":"Main","nestedDevices":[],"percentage":null,"usage":null}],"deviceGid":189565},{"channelUsages":[{"channelNum":"1,2,3","deviceGid":320302,"name":"Main","nestedDevices":[],"percentage":0.5470281824140429,"usage":0.004759628183477678}],"deviceGid":320302}],"percentage":83.98040129010761,"usage":0.7307036414032845},{"channelNum":"1","deviceGid":186656,"name":"2A - Plug for Living Room Entertainment Center UPS & Back Door + Inside Garage Door Doorbells","nestedDevices":[{"channelUsages":[{"channelNum":"1,2,3","deviceGid":191133,"name":"Main","nestedDevices":[],"percentage":null,"usage":null}],"deviceGid":191133},{"channelUsages":[{"channelNum":"1,2,3","deviceGid":191135,"name":"Main","nestedDevices":[],"percentage":null,"usage":null}],"deviceGid":191135},{"channelUsages":[{"channelNum":"1,2,3","deviceGid":320310,"name":"Main","nestedDevices":[],"percentage":2.9457394592502126,"usage":0.02563053422504924}],"deviceGid":320310},{"channelUsages":[{"channelNum":"1,2,3","deviceGid":320311,"name":"Main","nestedDevices":[],"percentage":4.19936077675763,"usage":0.0365381465675894}],"deviceGid":320311}],"percentage":3.5209028568929366,"usage":0.030634963622898873},{"channelNum":"2","deviceGid":186656,"name":"8A - Plugs & Lights North Bedrooms","nestedDevices":[],"percentage":5.337366752724333,"usage":0.04643980335659451},{"channelNum":"3","deviceGid":186656,"name":"10A - Basement Game Room Plugs & Lights","nestedDevices":[],"percentage":0.6753273001440817,"usage":0.005875943788952297},{"channelNum":"4","deviceGid":186656,"name":"6B - Walk-in Closet and On-Suite","nestedDevices":[],"percentage":0.839975967118878,"usage":0.00730853256755405},{"channelNum":"5","deviceGid":186656,"name":"10B - Plugs Dining Room + Aquarium + Sunroom (East)","nestedDevices":[],"percentage":3.456425940617338,"usage":0.030073957521650527},{"channelNum":"6","deviceGid":186656,"name":"12A - Dining Room Plugs - North","nestedDevices":[],"percentage":0.0005270339791115252,"usage":0.000004585660960939195},{"channelNum":"7","deviceGid":186656,"name":"4B - Kitchen Refrigerator","nestedDevices":[],"percentage":9.786523351738548,"usage":0.08515139413409763},{"channelNum":"8","deviceGid":186656,"name":"16A - Garage South & Ceiling Plugs","nestedDevices":[],"percentage":0.6343677783703703,"usage":0.005519559784465366},{"channelNum":"9","deviceGid":186656,"name":"16B - Cold Room Plugs (Dehumidifier & Fan)","nestedDevices":[],"percentage":1.8406621151028135,"usage":0.016015385607083637},{"channelNum":"10","deviceGid":186656,"name":"18B - Plugs & Lights South Bedrooms (Including Dimitri's Home Office)","nestedDevices":[{"channelUsages":[{"channelNum":"1,2,3","deviceGid":191130,"name":"Main","nestedDevices":[],"percentage":null,"usage":null}],"deviceGid":191130},{"channelUsages":[{"channelNum":"1,2,3","deviceGid":320255,"name":"Main","nestedDevices":[],"percentage":6.764951297821306,"usage":0.05886104937934108}],"deviceGid":320255}],"percentage":5.284742220414032,"usage":0.0459819234608621},{"channelNum":"11","deviceGid":186656,"name":"20B - Solar Braker Panel (Work Computer, Alexa devices and Battery Chargers)","nestedDevices":[{"channelUsages":[{"channelNum":"1,2,3","deviceGid":191141,"name":"Main","nestedDevices":[],"percentage":null,"usage":null}],"deviceGid":191141},{"channelUsages":[{"channelNum":"1,2,3","deviceGid":320239,"name":"Main","nestedDevices":[],"percentage":1.5226691227957692,"usage":0.01324856580329622}],"deviceGid":320239}],"percentage":2.479464484486878,"usage":0.02157353024887359},{"channelNum":"12","deviceGid":186656,"name":"13A - Cable + Basement South West Plugs + Garage Fridge + CO2 Monitor + Water Shutoff","nestedDevices":[{"channelUsages":[{"channelNum":"1,2,3","deviceGid":188827,"name":"Main","nestedDevices":[],"percentage":null,"usage":null}],"deviceGid":188827},{"channelUsages":[{"channelNum":"1,2,3","deviceGid":320243,"name":"Main","nestedDevices":[],"percentage":6.190839316327777,"usage":0.05386576823033338}],"deviceGid":320243}],"percentage":4.317174458048367,"usage":0.03756322961796544},{"channelNum":"13","deviceGid":186656,"name":"13B - Basement + Lights + Closet + Cold Room Lights + Basement Game Room North Plugs + Air Exchanger","nestedDevices":[{"channelUsages":[{"channelNum":"1,2,3","deviceGid":188837,"name":"Main","nestedDevices":[],"percentage":null,"usage":null}],"deviceGid":188837},{"channelUsages":[{"channelNum":"1,2,3","deviceGid":320270,"name":"Main","nestedDevices":[],"percentage":4.892781126735088,"usage":0.042571515865282336}],"deviceGid":320270}],"percentage":9.92351873114673,"usage":0.08634337489450362},{"channelNum":"14","deviceGid":186656,"name":"15A - Den & Dining Room High Plugs (Cameras)","nestedDevices":[],"percentage":1.7973058606563779,"usage":0.015638147912157906},{"channelNum":"15","deviceGid":186656,"name":"17B - Den East High Plugs + Main Entrance Closet Plug (Security System)","nestedDevices":[],"percentage":1.7471684246957182,"usage":0.015201907950639726},{"channelNum":"16","deviceGid":186656,"name":"6A - Basement Game Room West Plugs (Entertainment Center + 3D Printer)","nestedDevices":[],"percentage":5.275578731869279,"usage":0.04590219301965501}],"deviceGid":186656}],"percentage":31.876943296342414,"usage":0.27735755230532755},{"channelNum":"1","deviceGid":183930,"name":"1 - Den Bookcases, Printer, Old Light Plug & Lights (Den Center, Main Entrance, Outside Front) & Coffee Nook","nestedDevices":[{"channelUsages":[{"channelNum":"1,2,3","deviceGid":189564,"name":"Main","nestedDevices":[],"percentage":null,"usage":null}],"deviceGid":189564},{"channelUsages":[{"channelNum":"1,2,3","deviceGid":320230,"name":"Main","nestedDevices":[],"percentage":2.2333317662116317,"usage":0.019431958277921407}],"deviceGid":320230}],"percentage":2.7151859353266907,"usage":0.023624515000548095},{"channelNum":"2","deviceGid":183930,"name":"2 - Microwave","nestedDevices":[],"percentage":0.0,"usage":0.0},{"channelNum":"3","deviceGid":183930,"name":"4 - Outside + Bathroom Plugs","nestedDevices":[],"percentage":1.1204816857468545,"usage":0.009749179991086324},{"channelNum":"4","deviceGid":183930,"name":"18A - Den Computer","nestedDevices":[],"percentage":0.9169100068955974,"usage":0.007977926642232472},{"channelNum":"5","deviceGid":183930,"name":"6-7 - Mini-Split Heat Pump","nestedDevices":[],"percentage":0.0,"usage":0.0},{"channelNum":"6","deviceGid":183930,"name":"12-13 Oven","nestedDevices":[],"percentage":0.0,"usage":0.0},{"channelNum":"7","deviceGid":183930,"name":"14-15 Dryer","nestedDevices":[],"percentage":0.0,"usage":0.0},{"channelNum":"8","deviceGid":183930,"name":"16 - Garage North-East Plugs","nestedDevices":[],"percentage":0.9096084270323284,"usage":0.007914396450519562},{"channelNum":"9","deviceGid":183930,"name":"21 - Family Room Lights & Plugs + Kitchen Lights + Bathroom Lights + Outside Back Lights","nestedDevices":[],"percentage":3.0604679047533017,"usage":0.026628772999975417},{"channelNum":"10","deviceGid":183930,"name":"32 - Living Room (Subwoofer) + Kitchen (Toaster & Vitamix)","nestedDevices":[],"percentage":0.0,"usage":0.0},{"channelNum":"11","deviceGid":183930,"name":"36 - Washer","nestedDevices":[],"percentage":0.022401316509336675,"usage":0.00019491123278935748},{"channelNum":"12","deviceGid":183930,"name":"2B - Kitchen Fuse Panel (Kitchen Stove, Dish Washer, Insinkerator)","nestedDevices":[],"percentage":0.0,"usage":0.0},{"channelNum":"13","deviceGid":183930,"name":"4A - Kitchen Fuse Panel (Kitchen Stove, Island Plug, Dog Food Plug)","nestedDevices":[],"percentage":0.7590674423102155,"usage":0.006604556963841121},{"channelNum":"14","deviceGid":183930,"name":"34-35 Water Heater","nestedDevices":[],"percentage":0.0,"usage":0.0},{"channelNum":"15","deviceGid":183930,"name":"Rooftop Solar Panels","nestedDevices":[],"percentage":100.0,"usage":-0.5927307423184289},{"channelNum":"16","deviceGid":183930,"name":"EV Charger","nestedDevices":[],"percentage":0.0,"usage":0.0},{"channelNum":"TotalUsage","deviceGid":183930,"name":"TotalUsage","nestedDevices":[],"percentage":100.0,"usage":0.8700882946237565},{"channelNum":"Balance","deviceGid":183930,"name":"Balance","nestedDevices":[],"percentage":4.282144225106413,"usage":0.037258435661558065}],"deviceGid":183930}],"energyUnit":"KilowattHours","instant":"2024-09-01T20:46:06Z","scale":"1H"}}
It looks like you have multiple levels of nested devices, which my code does not check for. It would need additional loops around line 113, which is going to get ugly fast.
Loop through each devices
then each channelUsages
(the existing code does this much), then it will need to loop through each nestedDevices
and each channelUsages
(again). Because you have another layer of nesting after this, it would need to repeat again to loop through each nestedDevices
and each channelUsages
.
During each loop the code retrieves the device name and usage. It then tries to get the child device ID based on the name, or creates the child device if it does not exist. It uses the native Hubitat functions getChildDevice() and addChildDevice(), which is where it looks like the error was probably occurring before. Once it has the child device ID, it sends the usage value.
Yea, I would guess that it is how it works when a user has a second Vue to support more than 16 clamps. I suspect it’s the same as well when you use their plugs.
ChatGPT has been pretty good at fixing the errors - not sure if it can do the same with this… I’ll have to see if this is something I can try on an evening this week or next weekend…. (I have some ability with reading JSON code, but don’t know nearly enough to write it from scratch… VB was the only language I was able to write in, but that was over 25 years ago! And I was only scratching the surface I’m sure…)
Do you think the error checking that it recommended would be an issue to other users, or should be added to the base code?
I can't isolate the cause of the error. It could be due to a different model (I have only the Vue 2) or a change in the API. Since I do not understand what the additional code does, I don't want to add it to my driver. As best I can tell, it just suppresses the error, it does not actually fix anything.
If the problem is the nested devices, I'd rather just solve for that, but I haven't been able to think of a scalable way to write the code. I'll keep thinking about it though.
That would be my guess. I also have a Vue 2.
I have confirmed that it is indeed the problem. When I « un-nest » my sub-panel, then I have access to all devices except my plugs (which are nested under their relevant breaker).
I notice that the only unit option in the units drop-down is kWh. However, when getting device updates every minute and every hour, the unit seems to be Watts. (I assume Watt Hours since it is averaging for the minute…?)
Should Watt hour also be an option?
Parent Device Screen:
Child device in Hubitat:
Same Child device in Emporia indicating the unit is Watts:
I added the drop down for scalability, but never got around to adding additional units. It will accurately convert to kwh no matter what frequency you select.
Perfect then! Thanks!
I'm ordering some of the Emporia "Smart Plugs", to monitor the energy use of my wife's computer and a few other lights items that I don't really need to switch on/off from hubitat. Any hope these will show up in this driver? They look like nice units, if it turns out they integrate well with Hubitat I might like to buy more. They seem to work with Google Assistant and Alexa, but I've never gotten either of those platforms to work with Hubitat.
Also my child devices in hubitat are not nearly as clean as the screenshot of @Sebastien . Mine show many buttons and attributes, including "acceleration", "carbonDioxide", "carbonMonoxide", "motion", "smoke", "temperature", "water", and others. In the mix is "power" which seems to be in Watts. How do I clean it up? I didn't care much whether there were extra attributes on my screen, but now that I've seen your screenshot without all the noise I kind-of want it too.
I can't confirm if the plugs use the same API. I expect the driver would need to be modified to support them if it does.
Previous versions of the driver supported only the power attribute. The latest version of the driver uses a generic device that supports both power and energy, but it does come with the side effect of having other attributes that aren't used.
Don’t know if this helps answer the question, but I have 8 plugs and none are picked-up in Hubitat.
In the Emporia app, one is at the same level as the other breakers, and the others are sub-elements of some of my breakers.