Raspberry Pi
: 21 nov 2013 08:37
I didn't design pellmoncli.py to be used as a python module, only directly run as a program. If you look at the source you notice that the dbus connection stuff happens in the if __main__: clause, meaning it gets called only when run as a main program, not when importing it. Changed like this it should work also as a module:
# Connect to pellmonsrv on the dbus system bus
d = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
notify = Gio.DBusProxy.new_sync(d, 0, None, 'org.pellmon.int', '/org/pellmon/int', 'org.pellmon.int', None)
if __name__ == "__main__":
If you don't need any of the additional stuff pellmonsrv does (like data logging, email, settings/alarm monitoring) you could communicate directly with the burner from your own python program, skipping the server and dbus entirely. In the 'develop' branch I have made that a lot easier by breaking out the burner communication in its own python module 'Scotteprotocol'. After installing pellmon from develop you can just
import Scotteprotocol
p = Scotteprotocol.Protocol('/dev/ttyUSB0', 'auto')
print p.getItem('boiler_return_temp')
p.setItem('max_power', '75')
hope this helps.
# Connect to pellmonsrv on the dbus system bus
d = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
notify = Gio.DBusProxy.new_sync(d, 0, None, 'org.pellmon.int', '/org/pellmon/int', 'org.pellmon.int', None)
if __name__ == "__main__":
If you don't need any of the additional stuff pellmonsrv does (like data logging, email, settings/alarm monitoring) you could communicate directly with the burner from your own python program, skipping the server and dbus entirely. In the 'develop' branch I have made that a lot easier by breaking out the burner communication in its own python module 'Scotteprotocol'. After installing pellmon from develop you can just
import Scotteprotocol
p = Scotteprotocol.Protocol('/dev/ttyUSB0', 'auto')
print p.getItem('boiler_return_temp')
p.setItem('max_power', '75')
hope this helps.