MERGED: emonHub 'emon-pi' V2.0.0 - fixing thread is dead issue

Great @Dave, did you run sudo service emonhub restart at the end too?

Ah i see what you mean. i think this following condition will mean there isn’t (even if there are duplicates in the config file)…

… there shouldn’t be any duplicates.

yep, all working as it should be

@stuart
I get the following error when running the script…
ERROR MainThread Unable to create 'SMASolar' interfacer: __i__() got an unexpected keyword argument 'readdcvalues'

Regards
Dave

Hi @Dave

Take the “readdcvalues” parameter out of the emonHUB configuration file.

The only valid parameter values are:

  1. inverteraddress
  2. inverterpincode
  3. timeinverval
  4. nodeid
  5. packettrace

Thank You Stuart!
I don’t know how on earth “readdcvalues” got in the config fine.
It all working now :slight_smile:
Have you thought any more on pulling data from multiable interters?

Regards
Dave

Its really difficult to do this without having a 2nd inverter to test the code against

Where in the country are you based? as I have a spare inverter lying around that I’m due to put on eBay.

Regards
Dave

I’m in the Midlands, although strangely I’m looking to buy an inverter for some more panels I’m putting on my garage roof!!

Still working reliable for me on a couple of systems.

7 posts were split to a new topic: Sunny Boy inverters for sale

One week on now, no issues on our test systems.

@Dave @beaylott @stuart have you seen any issues?

We will move forward with merging this tomorrow or wednesday, if there are no issues.

1 Like

I must admit i’ve not tried it - but happy to have it merged if you are okay with the testing.

Hi Trystan
I don’t believe Ive had any issues following the update and Pushover is telling me that it last crashed 7 days ago.

Regards
Dave

1 Like

Great to see!

1 Like

Thanks for testing. PR has now been merging into default èmon-pi branch.

Update will be available to all emonPi’s via ‘emonPi Update’ via the web interface.

This new version is V2.0.0:

Those testing running the dev branch should change back to the emon-pi branch and pull in the changes.

2 Likes

Is this specific to the emon-pi or is it general as well? If so can we ditch a specific Emon-pi version; it just confuses anyone following on.

See EmonPi Crash and EmonHub still dying?

See emonTxV3 stops and requires reboot (emonhub) for issues relating to the http buffering

Further to the points I raise in that linked thread (send size throttling, max buffer size, log message text/positions and over-logging), the following issues also need to be tackled with the http buffering implementation.

  1. “if int(self._settings[‘senddata’]):” cannot be where it is currently as this switch doesn’t directly control whether the data is sent, it controls whether the data is passed to the interfacer, the data must be consumed, the interfacer cannot just say “no I do not want the data” because that leaves it backing up on the queue using up ram.
  2. The call to bulk post cannot reside inside the loop that adds the data to the buffer, if data is not regular the data in the buffer might never be sent if the network comes up after the last frame is put on the buffer.
  3. The sendinterval switch cannot stay where it is as it allows the interfacer to sit idle between sends and only when the interval has passed will it processes the queue into the buffer before trying to send.
  4. There are a lot of ifs and buts that prevent this code from doing anything at all unless all conditions met and then it does everything as one big packet, it empties the whole queue into the buffer, it then copies the whole buffer into a request and sends it, if it succeeds it deletes all of the “buffered” data directly from the queue, if it fails it will not retry again for 30secs and when it does retry it restarts from the beginning with an empty buffer, reloading every frame from the queue to the buffer, then to the request, this really isn’t the best way to do things.

These are just the “crucial” bits to make it work, there are also a number of things that are just not good practice, advisable or needed, mainly where inheritance and sub-classing has been ignored in favour of rewriting common code in multiple places, The biggest offender here is pretty much the whole action method which is most of the interfacer, most of this code should be in the run method of the basic interfacer and not over-ridden. The rest should be in the send method and most of whats in the send method belongs in the action method so that the data is sent regardless of whether/when any new data gets added to the buffer. The actual sending of the http request and the return of the response belongs in a separate method that belongs to a generic http interfacer class that this interfacer sub-classes, this is so that a (for example) pvoutput interfacer could also sub-class the generic http class and only the action method would be different as that is where the buffer gets parsed into a url and that generic “url_send_method” would get called and the raw reply passed back for that same action method to handle.

Just for the record, the action method is also where an independent and regular call to the emoncms/feed/fetch api could be made and that payload of feed values passed back into emonhub (remember why we made emonhub bidirectional and mulichannel) on a different channel that (for example) the MQTT interfacer is listening to, so that the data is published to the topic of your choice.

BUT, the mqtt development is blocked by the same things as this interfacer, it is too “bespoke” and written with an extremely narrow scope, plus the naming is no good, only a generic MQTT interfacer should be called mqttinterfacer, the bespoke emoncms mqtt interfacer should have been named emoncmsmqttinterfacer and the methods for subscribing and publishing should reside in the generic mqtt interfacer.

Getting processed feeds data from emoncms(org) on to mqtt should be as easy as defining a list of feed ids, an interval, a topic and a couple of other settings eg single mqtt topic or per value