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

Hi Trystan
I get the following error when trying to update…

error: Your local changes to the following files would be overwritten by checkout:
        src/emonhub.py
        src/interfacers/EmonHubMqttInterfacer.py
        src/interfacers/EmonModbusTcpInterfacer.py
Please, commit your changes or stash them before you can switch branches.
Aborting

How do you stash things in a pi?

Regards
Dave

What are the changes you have made? Happy to help with merging if it makes sense?

Hi Trystan
TBH I dont have a clue what changes Ive made, I was running Stuarts script that reads SMA inverters over bluetooth but that stopped working after an update.
I’m happy to make a backup and force git to do an update but I dont know the git commands

Regards
Dave

can you copy the results here of:

git diff
pi@emonpi(rw):emonhub$ git diff
diff --git a/src/emonhub.py b/src/emonhub.py
index aee21c0..acdbf40 100755
--- a/src/emonhub.py
+++ b/src/emonhub.py
@@ -138,6 +138,7 @@ class EmonHub(object):
                 if not I.isAlive():
                     #I.start()
                     self._log.warning(I.name + " thread is dead") # had to be r                                                                                                 estarted")
+                    self._exit = True

             # Sleep until next iteration
             time.sleep(0.2)
diff --git a/src/interfacers/EmonHubMqttInterfacer.py b/src/interfacers/EmonHubM                                                                                                 qttInterfacer.py
index d25958c..4f458cd 100644
--- a/src/interfacers/EmonHubMqttInterfacer.py
+++ b/src/interfacers/EmonHubMqttInterfacer.py
@@ -123,8 +123,14 @@ class EmonHubMqttInterfacer(EmonHubInterfacer):
                     payload = str(value)

                     self._log.info("Publishing: "+topic+" "+payload)
+
:...skipping...
diff --git a/src/emonhub.py b/src/emonhub.py
index aee21c0..acdbf40 100755
--- a/src/emonhub.py
+++ b/src/emonhub.py
@@ -138,6 +138,7 @@ class EmonHub(object):
                 if not I.isAlive():
                     #I.start()
                     self._log.warning(I.name + " thread is dead") # had to be restarted")
+                    self._exit = True

             # Sleep until next iteration
             time.sleep(0.2)
diff --git a/src/interfacers/EmonHubMqttInterfacer.py b/src/interfacers/EmonHubMqttInterfacer.py
index d25958c..4f458cd 100644
--- a/src/interfacers/EmonHubMqttInterfacer.py
+++ b/src/interfacers/EmonHubMqttInterfacer.py
@@ -123,8 +123,14 @@ class EmonHubMqttInterfacer(EmonHubInterfacer):
                     payload = str(value)

                     self._log.info("Publishing: "+topic+" "+payload)
+
                     result =self._mqttc.publish(topic, payload=payload, qos=2, retain=False)

+                    try:
+                        result =self._mqttc.publish(topic, payload=payload, qos=2, retain=False)
+                    except Exception as e:
+                        self._log.warning("Unable to publish: "+topic+" "+payload+" error: "+ str(e))
+
                     if result[0]==4:
                         self._log.info("Publishing error? returned 4")

diff --git a/src/interfacers/EmonModbusTcpInterfacer.py b/src/interfacers/EmonModbusTcpInterfacer.py
index 6afe843..27036b5 100644
--- a/src/interfacers/EmonModbusTcpInterfacer.py
+++ b/src/interfacers/EmonModbusTcpInterfacer.py
@@ -16,7 +16,7 @@ Monitors Solar Inverter using modbus tcp

Thanks @dave, the changes displayed are in relation to the proposed changes in the original thread here.

You can now discard these with

git checkout src/emonhub.py
git checkout src/interfacers/EmonHubMqttInterfacer.py

does it list any changes in: src/interfacers/EmonModbusTcpInterfacer.py? is what you copied in the full output?
If so you can also do:

git checkout src/interfacers/EmonModbusTcpInterfacer.py

Or all in one go with a single command:

git checkout .

Then you should be able to follow the steps above.

Thanks

Dave this script should be working fine in the current code base - isn’t yours ?

So there are no duplicate names in the “kill_list” variable ?

@stuart
No, I did an update once and I was never able to get it work again :frowning:
I’ll have a go again following your guide.

@TrystanLea
I’ve changed the branch and have the Your branch is up-to-date with 'origin/emon-pi-develop'.
All seems to be working so far

Regards
Dave

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