def deviceStartComm(self, dev): self.debugLog(u"%s starting communication" % dev.name) dev.stateListOrDisplayStateIdChanged() # Force plugin to refresh states from devices.xml 1.1.0 if self.cache is None: return if "lastreset" in dev.states: d = indigo.server.getTime() if dev.states["lastreset"] == "": dev.updateStateOnServer("lastreset", d.strftime("%Y-%m-%d ")) if self.cache.deviceInCache (dev.id) == False: self.debugLog(u"%s not in cache, appears to be a new device or plugin was just started" % dev.name) self.cache.cacheDevices() # Failsafe self.addWatchedStates("*", dev.deviceTypeId, dev.id) # Failsafe #self.cache.dictDump (self.cache.devices[dev.id]) self.updateDeviceStates(dev) dev.updateStateImageOnServer(indigo.kStateImageSel.None) dev.updateStateOnServer(key="statedisplay", value=True, uiValue="True") if dev.deviceTypeId == "epslcdwe": try: # 1.1.0 added preferences for speed if eps.propValid(dev, "speed", True) == False: props = dev.pluginProps props["speed"] = "mph" dev.replacePluginPropsOnServer(props) # 1.1.0 added preferences for pressure if eps.propValid(dev, "pressure", True) == False: props = dev.pluginProps props["pressure"] = "inHg" dev.replacePluginPropsOnServer(props) except: indigo.server.log("Error trying to save new device properties, please edit the device and re-save properties to get past this issue", isError=True) if dev.deviceTypeId == "epslcdir": # Extract zone names loop = 1 if eps.propValid (dev, "device", True): devEx = indigo.devices[int(dev.pluginProps["device"])] self.debugLog ("\tGetting zone names from %s" % devEx.name) for s in devEx.zoneNames: #def stringToLCD (self, value, length, padLeft = False): value = self.lcd.stringToLCD (s, 20, dev.pluginProps["textspaces"]) self.debugLog ("\t\t%s returned value is %s" % (s, value)) self.lcd.stringToGraphics (dev, "zonename" + str(loop) + "_", s) loop = loop + 1 return
def addWatchedStates (self, subDevId = "*", deviceTypeId = "*", mainDevId = "*"): if deviceTypeId == "*" or deviceTypeId == "epslcdsb": if mainDevId != "*": dev = indigo.devices[int(mainDevId)] devChild = indigo.devices[int(dev.pluginProps["device"])] subDevId = devChild.id # Must be specific for multiple choice for i in range (1, 6): if eps.propValid (dev, "state" + str(i), True): self.cache.addWatchState (dev.pluginProps["state" + str(i)], subDevId, "epslcdsb", dev.id) elif deviceTypeId == "*" or deviceTypeId == "epslcddt": # 1.12 dev = indigo.devices[int(mainDevId)] if dev.pluginProps["systemdate"] == False and dev.pluginProps["usevariable"] == False: if mainDevId != "*": devChild = indigo.devices[int(dev.pluginProps["device"])] subDevId = devChild.id # Must be specific for multiple choice if eps.propValid (dev, "state", True): if eps.propValid (devChild, dev.pluginProps["state"]): self.cache.addWatchState (dev.pluginProps["state"], subDevId, "epslcddt", dev.id) else: self.cache.addWatchProperty (dev.pluginProps["state"], subDevId, "epslcddt", dev.id) # Since properties don't auto-update, force an update here - the only thing we are doing # this on is lastChanged self.dateTimeDeviceUpdate (dev, dev.lastChanged) elif deviceTypeId == "*" or deviceTypeId == "epslcdalc": for s in plug.defAlarmClock: self.cache.addWatchState (s, subDevId, "epslcdalc") dev = indigo.devices[int(mainDevId)] elif deviceTypeId == "*" or deviceTypeId == "epslcdth": for s in plug.defThermostat: self.cache.addWatchState (s, subDevId, "epslcdth") dev = indigo.devices[int(mainDevId)] # If an extended device was configure then add watches for it if eps.propValid (dev, "device2", True): devExtended = indigo.devices[int(dev.pluginProps["device2"])] for s in plug.defThermostatEx: self.cache.addWatchState (s, devExtended.id, "*", dev.id) elif deviceTypeId == "*" or deviceTypeId == "epslcdwe": if mainDevId != "*": # self, stateName, subDevId = "*", deviceTypeId = "*", mainDevId = "*" dev = indigo.devices[int(mainDevId)] devChild = indigo.devices[int(dev.pluginProps["device"])] subDevId = devChild.id # Must be specific for multiple choice # If an extended device was configure then add watches for it if eps.propValid (dev, "device2", True): devExtended = indigo.devices[int(dev.pluginProps["device2"])] for s in plug.defWeatherEx: self.cache.addWatchState (s, devExtended.id, "*", dev.id) if devChild.pluginId == "com.fogbert.indigoplugin.wunderground": # Weather Underground plugin for s in plug.defWUnderground: self.cache.addWatchState (s, subDevId, "epslcdwe", dev.id) elif devChild.pluginId == "com.perceptiveautomation.indigoplugin.weathersnoop": # Weathersnoop plugin for s in plug.defWeathersnoop: self.cache.addWatchState (s, subDevId, "epslcdwe", dev.id) self.cache.addWatchState ("temperature_" + dev.pluginProps["temps"], subDevId, "epslcdwe", dev.id) self.cache.addWatchState ("dayRain_" + dev.pluginProps["measures"], subDevId, "epslcdwe", dev.id) self.cache.addWatchState ("rainOneHour_" + dev.pluginProps["measures"], subDevId, "epslcdwe", dev.id) # 1.1.0 from dewPoint to Pressure self.cache.addWatchState ("dewPoint" + dev.pluginProps["temps"], subDevId, "epslcdwe", dev.id) self.cache.addWatchState ("windChill" + dev.pluginProps["temps"], subDevId, "epslcdwe", dev.id) self.cache.addWatchState ("windSpeed_" + dev.pluginProps["speed"], subDevId, "epslcdwe", dev.id) self.cache.addWatchState ("windGust_" + dev.pluginProps["speed"], subDevId, "epslcdwe", dev.id) self.cache.addWatchState ("relativeBarometricPressure_" + dev.pluginProps["pressure"], subDevId, "epslcdwe", dev.id) elif devChild.pluginId == "com.perceptiveautomation.indigoplugin.NOAAWeather": # NOAA for s in plug.defNOAA: self.cache.addWatchState (s, subDevId, "epslcdwe", dev.id) elif deviceTypeId == "*" or deviceTypeId == "epslcdir": for s in plug.defSprinklers: self.cache.addWatchState (s, subDevId, "epslcdir") dev = indigo.devices[int(mainDevId)] # If an extended device was configure then add watches for it if eps.propValid (dev, "device2", True): devExtended = indigo.devices[int(dev.pluginProps["device2"])] for s in plug.defIrrigationEx: self.cache.addWatchState (s, devExtended.id, "*", dev.id) #self.cache.dictDump (self.cache.devices) return