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

Configurable timer, default value in config file 2000ms #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Within the project there is a file `/data/dbus-shelly-1pm-pvinverter/config.ini`
| DEFAULT | CustomName | Name shown in Remote Console (e.g. name of pv inverter) |
| DEFAULT | Phase | Valid values L1, L2 or L3: represents the phase where pv inverter is feeding in |
| DEFAULT | Position | Valid values 0, 1 or 2: represents where the inverter is connected (0=AC input 1; 1=AC output; 2=AC input 2) |
| DEFAULT | RefreshRate | Valid values are above 250: Refresh rate for timer in ms |
| ONPREMISE | Host | IP or hostname of on-premise Shelly 3EM web-interface |
| ONPREMISE | Username | Username for htaccess login - leave blank if no username/password required |
| ONPREMISE | Password | Password for htaccess login - leave blank if no username/password required |
Expand Down
1 change: 1 addition & 0 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Deviceinstance=41
CustomName=SUN-2000_GTIL
Phase=L3
Position=1
RefreshRate=2000

[ONPREMISE]
Host=192.168.178.146
Expand Down
6 changes: 5 additions & 1 deletion dbus-shelly-1pm-pvinverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ def __init__(self, servicename, paths, productname='Shelly 1PM', connection='She
self._lastUpdate = 0

# add _update function 'timer'
gobject.timeout_add(250, self._update) # pause 250ms before the next request
refreshRate = int(config['DEFAULT']['RefreshRate'])
MIN_REFRESH_RATE = 250
if not refreshRate or refreshRate < MIN_REFRESH_RATE:
refreshRate = MIN_REFRESH_RATE
gobject.timeout_add(refreshRate, self._update) # pause at least 250ms before the next request

# add _signOfLife 'timer' to get feedback in log every 5minutes
gobject.timeout_add(self._getSignOfLifeInterval()*60*1000, self._signOfLife)
Expand Down