Skip to content
This repository has been archived by the owner on Apr 30, 2022. It is now read-only.

Error setting up Integration #19

Closed
timsavory opened this issue Dec 8, 2020 · 18 comments · Fixed by #23
Closed

Error setting up Integration #19

timsavory opened this issue Dec 8, 2020 · 18 comments · Fixed by #23

Comments

@timsavory
Copy link

Added the source to custom components, added the integration, authenticated and then received this error in the logs:

Logger: homeassistant.components.sensor
Source: custom_components/hildebrandglow/sensor.py:55
Integration: Sensor (documentation, issues)
First occurred: 14:22:51 (2 occurrences)
Last logged: 14:26:08

Error while setting up hildebrandglow platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/hildebrandglow/sensor.py", line 55, in async_setup_entry
async_add_entities([sensor])
UnboundLocalError: local variable 'sensor' referenced before assignment

@timsavory
Copy link
Author

So i have determined that neither of the resourceTypeId values match the 4 entries received from glow.retrieve resources....

@techcubs
Copy link

techcubs commented Dec 9, 2020

I am having the same issue as well. I have the bright app registered and i am using the application id in their API PDF.

Logger: homeassistant.components.sensor
Source: custom_components/hildebrandglow/sensor.py:55
Integration: Sensor (documentation, issues)
First occurred: 12:00:38 (2 occurrences)
Last logged: 12:03:51

Error while setting up hildebrandglow platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/hildebrandglow/sensor.py", line 55, in async_setup_entry
async_add_entities([sensor])
UnboundLocalError: local variable 'sensor' referenced before assignment

I have tried adding 0.02 and the master builds via HACS

whenIi add the integration via config it says successfully added for . and does not show any entnties in the Hildebrand Glow Integration Card.

@timsavory
Copy link
Author

The reason is because your meter resource type id do not match those in the code, maybe they have changed? I fixed that so the integration loads but the readings are not working, seems that something may have changed in the glow API....

@techcubs
Copy link

techcubs commented Dec 9, 2020

as per their official repository url:
https://bitbucket.org/ijosh/brightglowmarkt/src/master/
the 4 resource type ID's in their Glowmarkt API Data Retrieval Documentation still seem to be the same as in the code.

@timsavory
Copy link
Author

yes i know but mine are: e3a5db34-6e0c-4221-9653-8d33e27511ba for electricity and 08ab415f-d851-423f-adf4-c2b1e0529e27 for gas. changing the code fixed this with one other small change in sensor.py....
i think the glow api is out of date, I have contacted customer support.....

@techcubs
Copy link

techcubs commented Dec 9, 2020

i have figured out my resource ID's as well by doing some curl commands. Will just changing these in the sensor.py (lines 66 and 67) get me to where you are at ?
did you also change the line 107 with identifiers?

@timsavory
Copy link
Author

I changed lined 66 and 67, line 107 I replaced with "Smart Meters, Gas & Electric" - no variable and also line 55 from async_add_entities([sensor]) to async_add_entities([new_entities]).

It integrates OK but I am now having problems with updates, it seems that step 4b in the glow api docs does not work for me....

@jrb80
Copy link

jrb80 commented Dec 12, 2020

I am experiencing the same issue. I am watching this thread for a solution.

@timsavory
Copy link
Author

I assume you mean step 4b? I expect my issue is that I do not yet have the CAD, I am relying on data from the meters only at this stage. Support at glowmarkt have kind of suggested this but not confirmed it. If anyone can get a reply from glowmarkt support to confirm this would be grateful (i.e that data is limited without the CAD - delayed 30 min readings is all that works, not instantaneous readings)

@arundalep
Copy link

I am not using this integration yet as I currently use Node Red to extract data from the MQTT stream and have done reliably since it became available. I only have the glow stick and not the CAD and can confirm instantaneous readings work perfectly with this setup. I am not sure if that answers your question but hope the info is helpful.

@jrb80
Copy link

jrb80 commented Dec 13, 2020

My log extract with the traceback error

2020-12-13 11:38:27 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up hildebrandglow platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/hildebrandglow/sensor.py", line 55, in async_setup_entry
async_add_entities([sensor])
UnboundLocalError: local variable 'sensor' referenced before assignment

@timsavory
Copy link
Author

See my earlier comment on this thread on how to fix this..

@timsavory
Copy link
Author

I am not using this integration yet as I currently use Node Red to extract data from the MQTT stream and have done reliably since it became available. I only have the glow stick and not the CAD and can confirm instantaneous readings work perfectly with this setup. I am not sure if that answers your question but hope the info is helpful.

Yes it makes sense...i have neither the stick nor CAD as they are out of stock...it seems that the glowmarkt api behaves differently in this case. MQTT is only available with one of their devices...

This was referenced Feb 20, 2021
@BertrumUK
Copy link

I have changed lines 66 and 67 and line 55 to async_add_entities(new_entities)

I get the sensors showing but no data and I get the following error

File "/config/custom_components/hildebrandglow/sensor.py", line 115, in state
return self._state["data"][0][1]
IndexError: list index out of range

I see a mention of changing line 107 but that doesn't make sense to me - can @timsavory share the config you have changed on 107 please ?

@alexhildebrand
Copy link

Good afternoon all,

Indeed the resourceTypeId may be different depending on where the data was sourced from on initial setup.

It is recommended that the "classifier" field on the resource should always be used to indicate the type of data stream. (See end of Step 3 section https://docs.glowmarkt.com/GlowmarktAPIDataRetrievalDocumentationIndividualUserForBright.pdf)

When there is a Glow CAD, IHD or a clamp transmitter, installed the /current API will return the latest power reading. If however the data is solely sourced from your smart meter via the DCC, only the 30 minute profile reads will be available, which means that no "instantaneous" power readings are available.

In such cases the /current endpoint will return something like this:
{ "status": "OK", "name": "electricity consumption", "resourceTypeId": "e3a5db34-6e0c-4221-9653-8d33e27511ba", "resourceId": "****************", "data": [], "classifier": "electricity.consumption" }

@BertrumUK
Copy link

That works fine for me using Postman but the code here doesn't work

{ "status": "OK", "name": "gas consumption", "resourceTypeId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "resourceId": "xxxxxxxxxxxxxxxxxxxxxx", "query": { "from": "2021-02-21T00:00:00", "to": "2021-02-21T23:59:59", "period": "P1D", "function": "sum" }, "data": [ [ 1613865600, 9.30542746 ] ], "units": "kWh", "classifier": "gas.consumption" }

@trinity-geology-unstable

I'm also hitting the same issues as others in this thread. I've set up the integration using HACS and entered an App ID, username, and password, but no entities have been added. I do not have a CAD only API access to my meter data. Due to owning a Honeywell smart meter I only have Gas data show up in the Bright App.

@unlobito
Copy link
Owner

Hello! 👋

@technofreak74 has sent in a pull request that will hopefully resolve the setup issues that folks in this issue have been experiencing. Please ping back with your experiences after installing the update.

Thanks for your patience & @technofreak74 for patching this!

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

Successfully merging a pull request may close this issue.

8 participants