Skip to content

Commit

Permalink
Make Domoticz hid and dunit configurable through ini file
Browse files Browse the repository at this point in the history
Domoticz hid and dunit values were hard coded. This commit makes them
configurable through the BS440.ini file.
  • Loading branch information
keptenkurk committed Sep 29, 2016
1 parent f395fb5 commit c140a5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions BS440.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
username: John
useremail: johndoe@gmail.com
domoticz_id: 55
domoticz_hid: 2
domoticz_dunit: 4
googleauthfile: google-john.json

[Person2]
username: Jill
useremail: jilldoe@gmail.com
domoticz_id: 56
domoticz_hid: 2
domoticz_dunit: 4
googleauthfile: google-jill.json

# Scale properties
Expand Down
9 changes: 6 additions & 3 deletions BS440domoticz.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ def UpdateDomoticz(config, weightdata):
if config.has_section(personsection):
domoticzid = config.get(personsection, 'domoticz_id')
scaleuser = config.get(personsection, 'username')
domoticzhid = config.get(personsection, 'domoticz_hid')
domoticzdunit = config.get(personsection, 'domoticz_dunit')
else:
log.error('Unable to update Domoticz: No details found in ini file '
'for person %d' % (weightdata[0]['person']))
return
try:
log.info('Updating Domoticz for user %s at index %s with weight %s' % (
scaleuser, domoticzid, weightdata[0]['weight']))
url = 'http://%s/json.htm?type=command&param=udevice&hid=2&' \
'did=%s&dunit=4&dtype=93&dsubtype=1&nvalue=0&svalue=%s' % (
domoticzurl, domoticzid, weightdata[0]['weight'])
url = 'http://%s/json.htm?type=command&param=udevice&hid=%s&' \
'did=%s&dunit=%s&dtype=93&dsubtype=1&nvalue=0&svalue=%s' % (
domoticzurl, domoticzhid, domoticzid, domoticzdunit,
weightdata[0]['weight'])
log.debug('calling url: %s' % (url))
req = urllib2.Request(url)
base64string = base64.encodestring('%s:%s' % (
Expand Down

0 comments on commit c140a5c

Please sign in to comment.