Comments (6)
HI @mpolak77 ,
thanks for the feedback - I agree, error handling is not the best - had a similar problem a few weeks ago.
But unfortunately I am missing a little bit of time to do so....
Would be happy for some support - proposals, code-snippets, etc..
Thx
from dbus-shelly-3em-smartmeter.
Here a first attempt which seems to work, and also prints exceptions more readable:
--- dbus-shelly-3em-smartmeter-master.py
+++ dbus-shelly-3em-smartmeter.py
@@ -104,7 +104,7 @@
def _getShellyData(self):
URL = self._getShellyStatusUrl()
- meter_r = requests.get(url = URL)
+ meter_r = requests.get(url = URL, timeout=5)
# check for response
if not meter_r:
@@ -158,14 +156,20 @@
logging.debug("House Reverse (/Ac/Energy/Revers): %s" % (self._dbusservice['/Ac/Energy/Reverse']))
logging.debug("---");
- # increment UpdateIndex - to show that new data is available
- index = self._dbusservice['/UpdateIndex'] + 1 # increment index
- if index > 255: # maximum value of the index
- index = 0 # overflow from 255 to 0
- self._dbusservice['/UpdateIndex'] = index
+ # increment UpdateIndex - to show that new data is available an wrap
+ self._dbusservice['/UpdateIndex'] = (self._dbusservice['/UpdateIndex'] + 1 ) % 256
#update lastupdate vars
self._lastUpdate = time.time()
+
+ except (ValueError, requests.exceptions.ConnectionError, requests.exceptions.Timeout, ConnectionError):
+ logging.critical('Error getting data from Shelly - check network or Shelly status. Setting power values to 0')
+ self._dbusservice['/Ac/L1/Power'] = 0
+ self._dbusservice['/Ac/L2/Power'] = 0
+ self._dbusservice['/Ac/L3/Power'] = 0
+ self._dbusservice['/Ac/Power'] = 0
+ self._dbusservice['/UpdateIndex'] = (self._dbusservice['/UpdateIndex'] + 1 ) % 256
+
except Exception as e:
logging.critical('Error at %s', '_update', exc_info=e)
@@ -233,7 +237,12 @@
logging.info('Connected to dbus, and switching over to gobject.MainLoop() (= event based)')
mainloop = gobject.MainLoop()
mainloop.run()
+
+ except (ValueError, requests.exceptions.ConnectionError, requests.exceptions.Timeout) as e:
+ logging.critical('Error in main type %s', str(e))
+
except Exception as e:
logging.critical('Error at %s', 'main', exc_info=e)
+
if __name__ == "__main__"
```:
from dbus-shelly-3em-smartmeter.
@mpolak77 Good idea, but only works if the gridpower set point is 0 Watt. It would be better to set it to "/Settings/Cgwacs/AcPowerSetPoint". Then it is aligned to target of ESS control loop.
Another point: If the json decoding fails -> is this catched by ValueError? or should we add requests.exceptions.JSONDecodeError
from dbus-shelly-3em-smartmeter.
Good point - just realized that Multiplus starts to charge, if SetPoiint is >0 and Meter reads 0 ….
Now I need to find out, how to do this correctly depending on 1phase vs all phase Saldo mode.
from dbus-shelly-3em-smartmeter.
@mpolak77 thank you for your input - will add that to the next commit
from dbus-shelly-3em-smartmeter.
Should be all in now.
Thanks for the input
from dbus-shelly-3em-smartmeter.
Related Issues (20)
- Not running as service at v2.93 large after shutdown / reboot HOT 5
- there is a problem with the service when the raspberry reboot HOT 4
- support for 1EM HOT 3
- Shelly pro 3em HOT 9
- Dbus hangs sometimes and script needs to be restarted HOT 1
- Service stops if shelly is not reachable HOT 15
- IP V6 HOT 3
- Shelly 1PM Plus as smartmeter
- Log goes too big HOT 21
- Shelly 3EM not in "energy meter" HOT 6
- performance tweaks HOT 2
- Shelly Em Freezes after a while
- Not working with Shelly 3em pro HOT 2
- AC Load is not shown correctly
- Shelly 3EM PV Inverter
- Uninstall is not working HOT 2
- Shelly Pro 3EM wird nicht unter Energy Meter angezeigt HOT 1
- AC Input missing total in VRM Portal HOT 1
- Automatic logfile rotation seems to be missing HOT 3
- Option: Invert value of Shelly 3EM HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dbus-shelly-3em-smartmeter.