question

mcfrojd avatar image
mcfrojd asked

The use of the scripts for Shelly EM and Plug S in a campervan (VenusOS)

I have found a good use of using these Shelly "EM" and "Plug S" scripts that are out there.

( fabian-lauer, vikt0rm, halmand, vincegod and more )

And from what i have understand most users of these scrips use them in an enviroment where these shelly devices are constantly powered on.


In my campervan my shelly devices will only be powered on when im connected to shore power.


I use 1 Shelly "EM" to measure the total consumption from the shorepower and

1 shelly "Plug S" controll and measure the draw from my heated floors.


I want to see the current total draw to make sure i dont trip the fuse on the shore power connection, and the "Plug S" shows me if the floor heating is on and what level is set.

(the level is set manually from 0 to 3 under the bed)


Now to my question:

Is there a way to modify the python script so the current.log is NOT flooded when the shelly devices is offline ?

Im not good enough to solve this problem my self.


The flooding error message in the current.log looks like this:

Traceback (most recent call last):
  File "/data/dbus-shelly-em-smartmeter/dbus-shelly-em-smartmeter.py", line 212, in main
    pvac_output = DbusShellyemService(
  File "/data/dbus-shelly-em-smartmeter/dbus-shelly-em-smartmeter.py", line 47, in __init__
    self._dbusservice.add_path('/FirmwareVersion', self._getShellyFWVersion())
  File "/data/dbus-shelly-em-smartmeter/dbus-shelly-em-smartmeter.py", line 79, in _getShellyFWVersion
    meter_data = self._getShellyData()
  File "/data/dbus-shelly-em-smartmeter/dbus-shelly-em-smartmeter.py", line 118, in _getShellyData
    meter_r = requests.get(url = URL)
  File "/usr/lib/python3.8/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.77.201', port=80): Max retries exceeded with url: /status (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xb5b88970>: Failed to establish a new connection: [Errno 113] No route to host'))

Maybe there is a way to sense the "Errno 113" and stop writing it to the log after x times ?

modifications
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

1 Answer
gerard-van-seventer avatar image
gerard-van-seventer answered ·

Use try: and except: for this. There are many online examples so search for one close to your problem. e.g. this

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources

Experiments, Modifications and Adaptions. Mods (Modifications) can be made to Victron Software by the Community. Please use the modifications space for enthusiasts who want to push what is possible, without official Victron Support.