comparison eprodbus.py @ 19:3a3dba401b4a

Hook up more stuff.. - Battery temperature - Aux voltage - Low/high main/aux voltage, and flat battery alarms
author Daniel O'Connor <darius@dons.net.au>
date Mon, 06 Dec 2021 22:32:32 +1030
parents 9c2e08444598
children 8d48ca5294d3
comparison
equal deleted inserted replaced
18:9c2e08444598 19:3a3dba401b4a
69 self.dbusservice['/Soc'] = p.soc 69 self.dbusservice['/Soc'] = p.soc
70 elif type(p) == epro.MainVoltage: 70 elif type(p) == epro.MainVoltage:
71 self.dbusservice['/Dc/0/Voltage'] = p.volts 71 self.dbusservice['/Dc/0/Voltage'] = p.volts
72 elif type(p) == epro.BatteryCurrent: 72 elif type(p) == epro.BatteryCurrent:
73 self.dbusservice['/Dc/0/Current'] = p.amps 73 self.dbusservice['/Dc/0/Current'] = p.amps
74 elif type(p) == epro.BatteryTemperature:
75 self.dbusservice['/Dc/0/Temperature'] = p.temp
74 elif type(p) == epro.AmpHours: 76 elif type(p) == epro.AmpHours:
75 self.dbusservice['/ConsumedAmphours'] = p.amphrs 77 self.dbusservice['/ConsumedAmphours'] = p.amphrs
76 elif type(p) == epro.TimeRemaining: 78 elif type(p) == epro.TimeRemaining:
77 # ePro reports in minutes, Venus expects seconds 79 # ePro reports in minutes, Venus expects seconds
78 self.dbusservice['/TimeToGo'] = p.time * 60 80 self.dbusservice['/TimeToGo'] = p.time * 60
81 elif type(p) == epro.AuxVoltage:
82 self.dbusservice['/Dc/1/Voltage'] = p.volts
83 elif type(p) == epro.MonitorStatus:
84 self.dbusservice['/Alarms/LowVoltage'] = 2 if p.mainlv else 0
85 self.dbusservice['/Alarms/HighVoltage'] = 2 if p.mainhv else 0
86 self.dbusservice['/Alarms/LowStarterVoltage'] = 2 if p.auxlv else 0
87 self.dbusservice['/Alarms/HighStarterVoltage'] = 2 if p.auxhv else 0
88 self.dbusservice['/Alarms/LowSoc'] = 2 if p.batflat else 0
89 self.dbusservice['/Settings/HasTemperature'] = 1 if p.tempsense else 0
79 return True 90 return True
80 91
81 def log_epro(self): 92 def log_epro(self):
82 logger.debug('Logging epro data') 93 logger.debug('Logging epro data')
83 # Check we have all the packets we need in the queue 94 # Check we have all the packets we need in the queue
160 dbusservice.add_path('/ProductName', value = 'Enerdrive ePro') 171 dbusservice.add_path('/ProductName', value = 'Enerdrive ePro')
161 dbusservice.add_path('/Mgmt/Connection', value = '/dev/' + port) 172 dbusservice.add_path('/Mgmt/Connection', value = '/dev/' + port)
162 dbusservice.add_path('/DeviceInstance', value = instance) 173 dbusservice.add_path('/DeviceInstance', value = instance)
163 dbusservice.add_path('/ProductId', value = 'unknown') 174 dbusservice.add_path('/ProductId', value = 'unknown')
164 dbusservice.add_path('/Dc/0/Voltage', value = None) 175 dbusservice.add_path('/Dc/0/Voltage', value = None)
176 dbusservice.add_path('/Dc/0/Temperature', value = None)
165 dbusservice.add_path('/Dc/0/Current', value = None) 177 dbusservice.add_path('/Dc/0/Current', value = None)
178 dbusservice.add_path('/Dc/1/Voltage', value = None)
166 dbusservice.add_path('/Soc', value = None) 179 dbusservice.add_path('/Soc', value = None)
167 dbusservice.add_path('/TimeToGo', value = None) 180 dbusservice.add_path('/TimeToGo', value = None)
168 dbusservice.add_path('/ConsumedAmphours', value = None) 181 dbusservice.add_path('/ConsumedAmphours', value = None)
182 dbusservice.add_path('/Alarms/LowVoltage', value = 0)
183 dbusservice.add_path('/Alarms/HighVoltage', value = 0)
184 dbusservice.add_path('/Alarms/LowStarterVoltage', value = 0)
185 dbusservice.add_path('/Alarms/HighStarterVoltage', value = 0)
186 dbusservice.add_path('/Alarms/LowSoc', value = 0)
187 dbusservice.add_path('/Settings/HasTemperature', value = 0)
169 188
170 s = serial.Serial('/dev/' + port, 2400, parity = 'E') 189 s = serial.Serial('/dev/' + port, 2400, parity = 'E')
171 s.timeout = 0.1 190 s.timeout = 0.1
172 191
173 dbh = sqlite3.connect(dbpath) 192 dbh = sqlite3.connect(dbpath)