Skip to content

Commit

Permalink
generator: notify Multi when generator is running.
Browse files Browse the repository at this point in the history
If a digital input is used to monitor a generator, relay
that information to any Multis, so they can implement
any relevant functionality: Such as disabling "prefer
renewable energy".

victronenergy/venus#1052
  • Loading branch information
izak committed Jun 29, 2023
1 parent 9a2da78 commit cb99e1e
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions dbus_digitalinputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,29 @@ def get_alarm_state(self, level):
(level ^ self.settings['invertalarm']) and self.settings['alarm'])


class Generator(PinAlarm):
_product_name = "Generator"
type_id = 9
translation = 5 # running, stopped

def toggle(self, level):
super(Generator, self).toggle(level)

# Follow the same inversion sense as for display
v = level ^ self.settings['invert']

# Find all vebus services, and let them know
try:
services = [n for n in self.bus.list_names() if n.startswith(
'com.victronenergy.vebus.')]
for n in services:
self.bus.call_async(n, '/Ac/Control/RemoteGeneratorSelected', None,
'SetValue', 'v', [v], None, None)
except dbus.exceptions.DBusException:
print ("DBus exception setting RemoteGeneratorSelected")
traceback.print_exc()


# Various types of things we might want to monitor
class DoorSensor(PinAlarm):
_product_name = "Door alarm"
Expand Down Expand Up @@ -429,11 +452,6 @@ class CO2Alarm(PinAlarm):
type_id = 8
translation = 4 # ok, alarm

class Generator(PinAlarm):
_product_name = "Generator"
type_id = 9
translation = 5 # running, stopped

class GenericIO(PinAlarm):
_product_name = "Generic I/O"
type_id = 10
Expand Down

0 comments on commit cb99e1e

Please sign in to comment.