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

Loop energy component not working #8137

Closed
brinzlee opened this issue Jun 21, 2017 · 44 comments · Fixed by pavoni/pyloopenergy#28 or #12817
Closed

Loop energy component not working #8137

brinzlee opened this issue Jun 21, 2017 · 44 comments · Fixed by pavoni/pyloopenergy#28 or #12817

Comments

@brinzlee
Copy link

brinzlee commented Jun 21, 2017

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version):
47.0

Python release (python3 --version):
3.4.2

Component/platform:
Loop Energy

Description of problem:

I have followed the example of extracting the key and inserting them. But it returns an error every time

Expected:

Problem-relevant configuration.yaml entries and steps to reproduce:

sensor:
  - platform: loopenergy
    electricity:
      electricity_serial: 'ELECTRICAL_SERIAL'
      electricity_secret: 'ELECTRICAL_SECRET'
    gas:
      gas_serial: 'GAS_SERIAL'
      gas_secret: 'GAS_SECRET'

Traceback (if applicable):

2017-06-21 10:58:06 ERROR (LoopEnergy Event Thread) [pyloopenergy.loop_energy] Could not connect to https://www.your-loop.com
2017-06-21 10:58:06 ERROR (LoopEnergy Event Thread) [pyloopenergy.loop_energy] Please check your keys are correct. Terminating

Additional info:
I have followed the example of extracting the key and inserting them. But it returns an error every time

@matthewcky2k
Copy link
Contributor

Used to work fine for me until I upgraded to 47.1 now the log just says the component is initialised but doest get any data.

@Coedy
Copy link

Coedy commented Jul 16, 2017

Same issue here, worked fine but has been broken since update. About to update to the new release going it's fixed but don't see anything in the change log about it.
I get this error in the log:

2017-07-16 00:13:05 ERROR (LoopEnergy Event Thread) [pyloopenergy.loop_energy] Could not connect to https://www.your-loop.com
2017-07-16 00:13:05 ERROR (LoopEnergy Event Thread) [pyloopenergy.loop_energy] Please check your keys are correct. Terminating

Despite no changes to my secret key/serial in the config. Front end is there in the UI but just states "unknown"
Hope that helps!

@BenWoodford
Copy link

Mine isn't pulling data either, except I don't even get any errors in the logs. I have a "Power Usage" item in HASS but it's permanently at 0.

@brinzlee
Copy link
Author

I still can't get this sensor to work runnig Hass.IO now version 0.53.1. I never have got this working on any version I've had so far

@rt45433
Copy link

rt45433 commented Nov 22, 2017

Hi there, I have just tried to setup the loop as above and just like BenWoodford. It all shows up in HA as "Power Usage" but reading is permanently 0. Can someone please look at this. I would be very grateful.

@brinzlee
Copy link
Author

I also tried a new install from HassIO.....now version 0.57.3...I have no idea how others have managed to get this working.....I can only assume that they have been using a very early version of HomeAssistant.
I flagged this back in June.....but I guess because of its limited market no one can be bothered to address it !!

@rt45433
Copy link

rt45433 commented Nov 22, 2017

Yeah its a shame. I only went out and bought one of these loop devices purely to use through home assistant as it has it listed a component. Currently, no use to me if not working.

@matthewcky2k
Copy link
Contributor

Strange it works fine for me after I deleted my DB file it's working for me on. 58

@rt45433
Copy link

rt45433 commented Nov 22, 2017

Hi Matthew, do you know how I can delete my DB file? It's worth a try.

@rt45433
Copy link

rt45433 commented Nov 22, 2017

Update, I start home assistant, deleted the DB and restarted. This created the new DB and sadly still not got loop energy working.

@brinzlee
Copy link
Author

I deleted my DB too with no resolution.....Matthew would you be kind enough to copy your entry in the configuration.yaml and redact the sensitive user information. I would just like to see if there is any difference to what I have.
Thanks

@matthewcky2k
Copy link
Contributor

matthewcky2k commented Nov 22, 2017

 sensor 3:
  platform: loopenergy
  electricity:
    electricity_serial: redacted
    electricity_secret: redacted
  gas:
   gas_serial: redacted
   gas_secret: redacted
   gas_type: metric

@brinzlee
Copy link
Author

Do you have the information that has been redacted in any form of quotes.

@matthewcky2k
Copy link
Contributor

Nope

@matthewcky2k
Copy link
Contributor

Think that's you problem if your using quote marks they are not required

@brinzlee
Copy link
Author

Just doesn't want to play ball....the example gives quotes
https://home-assistant.io/components/sensor.loop_energy/
.....but I have now removed them....reset the DB....I don't even get 0 as a reading all I get is
Power Usage unknown kW
Gas Usage unknown kW

@brinzlee
Copy link
Author

Looking at the source code on github....it's been removed so I guess that doesn't bode well
https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/sensor/loop_energy.py

@MartinHjelmare
Copy link
Member

@brinzlee
Copy link
Author

Thanks....That was the link on the LoopEnergy page....
I have written an email to one of the authors asking for his assistance....

@rt45433
Copy link

rt45433 commented Nov 23, 2017

Please keep us posted on your outcome.

@fabaff
Copy link
Member

fabaff commented Nov 25, 2017

Can somebody please check manually if the connection works? In your venv if needed.

$ python3
>>> import pyloopenergy
>>> elec_serial = 'your serial'
>>> elec_secret = 'your_secret'
>>> le = pyloopenergy.LoopEnergy(elec_serial, elec_secret)
>>> le.electricity_useage
[Should be the value]
>>> le.terminate()

@brinzlee
Copy link
Author

Thanks for your help with this Fabian....I am not very knowledgeable with use of the command line so not really sure how to test this. Is there anybody else that has loopenergy who can try this. I originally started this thread back in June but haven’t really had any success with it. There are a few other users who are experiencing the same issues and some that have it working with exactly the same config.yaml. It’s very frustrating.

@BenWoodford
Copy link

BenWoodford commented Nov 27, 2017

>>> import pyloopenergy
>>> elec_serial = 'foo'
>>> elec_secret = 'bar'
>>> le = pyloopenergy.LoopEnergy(elec_serial, elec_secret)
>>> le.electricity_usage
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: LoopEnergy instance has no attribute 'electricity_usage'
>>> le
<pyloopenergy.loop_energy.LoopEnergy instance at 0x7f918c545bd8>
>>> from pprint import pprint
>>> pprint(vars(le))
{'_elec_callback': None,
 '_event_thread': <Thread(LoopEnergy Event Thread, started 140263043999488)>,
 '_gas_callback': None,
 'connected_ok': True,
 'elec_kw': 0.609,
 'elec_secret': 'foo',
 'elec_serial': 'bar',
 'gas_device_timestamp': None,
 'gas_kw': None,
 'gas_meter_calorific': 39.11,
 'gas_meter_type': 'metric',
 'gas_old_reading': None,
 'gas_old_timestamp': None,
 'gas_reading': None,
 'gas_secret': None,
 'gas_serial': None,
 'reconnect_needed': False,
 'thread_exit': False,
 'updated_in_interval': True}

For the record, I have no gas monitor any more (smart meter, not compatible) which is why there's no secret/serial there.

The elec_kw is indeed accurate.

EDIT: Oh, it's useage not usage (spelling is wrong then...), that does spit out the value.

@brinzlee
Copy link
Author

Where did you type that in Ben.....I'm not so good with Python....You wrote earlier in this thread yours wasn't working either.....although the script looks like it's outputting your electricity value

@BenWoodford
Copy link

pyloopenergy is the library, so there's an issue with the Home Assistant implementation, not the library which spits it out fine.

@MartinHjelmare
Copy link
Member

MartinHjelmare commented Nov 27, 2017

@BenWoodford Can you make a PR with the fix? Otherwise I can make one, if you can test it.
Edit: Nevermind, I thought you had found the cause.

@brinzlee
Copy link
Author

@fabaff So @BenWoodford has run the script and deduced that it is a problem with the Home Assistant implementation...Is this something you can look at, or recommend how we can get a resolution.

@BenWoodford
Copy link

BenWoodford commented Dec 28, 2017

I’ve just been having a tinker with this and added some more debug lines to see if any callbacks are firing.

Unfortunately, it doesn’t seem like anything is firing at all. The callbacks work perfectly when done through the example script but through HASS everything sets up correctly, the web socket doesn’t show any errors (or lack of polling) but it never fires the callback in the component to update things and I’m not sure it ever fires the callback within the library that updates its internal values and subsequently calls the callback from the component either.

Very strange. It’s the same version too.

Maybe @pavoni can shed some light

@BenWoodford
Copy link

BenWoodford commented Jan 11, 2018

The plot thickens!

I just setup a dev HASS environment, for unrelated reasons. Guess what? No issues with Loop, I get my power usage as expected.

That makes absolutely 0 sense.

To those on this issue, are you using the Docker container? And if not, what version of Python do you have installed?

Update: Just tried the code @fabaff provided, but in my Docker container instead.

>>> Exception in thread LoopEnergy Event Thread:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.6/site-packages/pyloopenergy/loop_energy.py", line 134, in _run_event_thread
    Namespace) as socket_io:
  File "/usr/local/lib/python3.6/site-packages/socketIO_client/__init__.py", line 356, in __init__
    resource, hurry_interval_in_seconds, **kw)
  File "/usr/local/lib/python3.6/site-packages/socketIO_client/__init__.py", line 54, in __init__
    self._transport
  File "/usr/local/lib/python3.6/site-packages/socketIO_client/__init__.py", line 62, in _transport
    self._engineIO_session = self._get_engineIO_session()
  File "/usr/local/lib/python3.6/site-packages/socketIO_client/__init__.py", line 76, in _get_engineIO_session
    transport.recv_packet())
StopIteration

This appears to be related to pavoni/pyloopenergy#26

So it's environment specific, fantastic.

@pavoni
Copy link
Contributor

pavoni commented Jan 11, 2018

I also couldn't get this working in hassio, I couldn't work out how to debug - so ended up switching back to run HA on my mac mini.

Very interesting it's the same error.

BTW I'm sure people realised - but any exception on that thread kills the monitoring - and it won't restart until you reload HA.

@adsmf
Copy link
Contributor

adsmf commented Feb 28, 2018

I found that switching to socketIO client 0.5.7.2 seems to bring this back to life (the default installed is 0.5.6)

Loop use the 0.9 protocol and https://github.com/invisibleroads/socketIO-client says

If you want to communicate using socket.io protocol 0.9 (which is compatible with gevent-socketio), please use socketIO-client 0.5.7.2.

@Coedy
Copy link

Coedy commented Feb 28, 2018

Adsmf - That's great!!
Could you knock up a quick how to? I'm a terrible newbie....
This would be really handy to get working given the cold snap and the start of the new month!

@adsmf
Copy link
Contributor

adsmf commented Feb 28, 2018

I achieved my change the hacky way - by logging into hass via the resin.os core ssh, jumping into the homeassistant container and running
pip3 install socketIO-client==0.5.7.2
Not sure it'd be the recommended approach (in fact I'm pretty sure it's not!).

I'll see if I can work out a more friendly way (other than the component itself being updated).

@Coedy
Copy link

Coedy commented Feb 28, 2018

Ahhh, I'm on Hassbian at the moment so imagine I would only need the Hacky install script, I'll hang on until yourself or someone works out a more eluant solution.

If I get bored though I'll totally do a backup of my install and use the quick and dirty method. So thanks again!

@brinzlee
Copy link
Author

So who do we have to get to fix this.....There are so many clever people that must be able to address the issue...?

@adsmf
Copy link
Contributor

adsmf commented Feb 28, 2018

So, I think the proper long term solution will be to get pyloopenergy to up the version in the requirements file - though I'm not sure if there's any other reason they've locked it to 0.5.6.

I think that a quick and dirty custom component may provide a temporary patch (I'm sure someone who knows better is going to shout at me for this suggestion).

In your config directory under the custom_components directory try creating a force_versions.py containing:

DOMAIN = 'force_versions'

REQUIREMENTS = [
    'socketIO-client==0.5.7.2'
]

def setup(hass, config):
    return True

Then add:

force_versions:

to your config.

@pavoni
Copy link
Contributor

pavoni commented Mar 1, 2018

Thanks for tracking this down @adsmf

Have released pyloopenergy 0.0.18 with the change in library.

I'm not in the same place as my HA - so I tested the library works stand alone - but can't test it in HA/hassio.

If someone can check this works OK we can close the issue and get it in the next HA release.

@brinzlee
Copy link
Author

brinzlee commented Mar 1, 2018

I will try and test it....But have no idea what to do !!

@adsmf
Copy link
Contributor

adsmf commented Mar 1, 2018

@pavoni Thanks for the quick turnaround on that - I'll create a temporary custom component that pulls the new version and report back :)

@adsmf
Copy link
Contributor

adsmf commented Mar 1, 2018

Turns out that was faster than I thought to test. That's working well on my hass.io instance.

@matthewcky2k
Copy link
Contributor

I assume this will also fix this issue?

#9687

@brinzlee
Copy link
Author

brinzlee commented Mar 1, 2018

@adsmf so what did you do to make it work.....Do I have to wait for the next version of Hass.IO to come out or is there some code I can update....

@adsmf
Copy link
Contributor

adsmf commented Mar 1, 2018

The easiest and cleanest way is certainly to wait for a release with the update. The way I tested the update library was to clone the contents of https://github.com/home-assistant/home-assistant/blob/0.64.1/homeassistant/components/sensor/loopenergy.py into /config/custom_components/sensor/loopenergy.py and modify the requirements line (https://github.com/home-assistant/home-assistant/blob/0.64.1/homeassistant/components/sensor/loopenergy.py#L20) to be for version 0.0.18.

If you do go down that route you'll want to remove the custom component when the release rolls around so you don't miss out on any other changes to the file (as the custom version would always override).

@brinzlee
Copy link
Author

brinzlee commented Mar 1, 2018

Thanks for the heads up Alex.....I might wait for the next release then....

@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
9 participants