insert state (temperaturef) for device "weather station_kbur" into variable: weathercurrenttemp
##var ref
#indigo.devices[204052749] # "weather station_van nuys"
#indigo.devices[228772392] # "weather station_burbank"
#indigo.variables[41620001] # "Weather_Condition"
#indigo.variables[162814321] # "WeatherCurrentHumidity"
#indigo.variables[1354783145] # "WeatherCurrentTemp"
#indigo.variables[1787162613] # "WeatherCurrentWindSpeed"
##init stations
kbur = indigo.devices[228772392]
kvny = indigo.devices[204052749]
##determine which station to use-- if bur is updated more recently than vny, use bur, else use vny
#curdatetime #(this has to be local i think), also maybe don't want to use this anyway
if kbur.states['lastChanged'] > kvny.states['lastChanged']
wthrStation = indigo.devices[228772392]
else:
wthrStation = indigo.devices[204052749]
##set temp vars from station info ###does this need str() ?
cnttemp = wthrStation.states['temperatureF']
cnthumid = wthrStation.states['humidity']
cntwind = wthrStation.states['windMPH']
cntcond= wthrStation.states['currentCondition']
##update ind vars
indigo.variable.updateValue(1354783145, str(cnttemp))
indigo.variable.updateValue(162814321, str(cnthumid))
indigo.variable.updateValue(1787162613, str(cntwind))
indigo.variable.updateValue(41620001, str(cntcond))
##var ref
#indigo.devices[204052749] # "weather station_van nuys"
#indigo.devices[228772392] # "weather station_burbank"
#indigo.variables[41620001] # "Weather_Condition"
#indigo.variables[162814321] # "WeatherCurrentHumidity"
#indigo.variables[1354783145] # "WeatherCurrentTemp"
#indigo.variables[1787162613] # "WeatherCurrentWindSpeed"
##init stations
kbur = indigo.devices[228772392]
kvny = indigo.devices[204052749]
##determine which station to use-- if bur is updated more recently than vny, use bur, else use vny
#curdatetime #(this has to be local i think), also maybe don't want to use this anyway
if kbur.lastChanged > kvny.lastChanged:
wthrStation = indigo.devices[228772392]
else:
wthrStation = indigo.devices[204052749]
##set temp vars from station info ###does this need str() ?
cnttemp = wthrStation.states['temperatureF']
cnthumid = wthrStation.states['humidity']
cntwind = wthrStation.states['windMPH']
cntcond= wthrStation.states['currentCondition']
##update ind vars
indigo.variable.updateValue(1354783145, str(cnttemp))
indigo.variable.updateValue(162814321, str(cnthumid))
indigo.variable.updateValue(1787162613, str(cntwind))
indigo.variable.updateValue(41620001, str(cntcond))
if kbur.lastChanged > kvny.lastChanged
from datetime import datetime
timeDelta = datetime.now() - kbur.lastChanged
if timeDelta.seconds > 7200:
#if kvny.lastChanged > kbur.lastChanged:
wthrStation = indigo.devices[204052749]
indigo.variable.updateValue(752974756, "KVNY") # "WeatherCurrentStation"
indigo.server.log("KBUR Time Since Update: "+ str(timeDelta), type="Irrigation:")
Jan 28, 2022 at 3:44:07 PM
Irrigation: KBUR Time Since Update: 15:14:00.498093
from datetime import datetime
timeDelta = datetime.now() - kbur.lastChanged
if timeDelta.seconds > 7200:
#if kvny.lastChanged > kbur.lastChanged:
wthrStation = indigo.devices[204052749]
indigo.variable.updateValue(752974756, "KVNY") # "WeatherCurrentStation"
indigo.server.log("KBUR Time Since Update: "+ str(timeDelta.strftime("%H:%M")), type="Irrigation:")
indigo.server.log("KBUR Time Since Update: "+ str(timeDelta.strftime("%H:%M")), type="Irrigation:")
AttributeError: 'datetime.timedelta' object has no attribute 'strftime'
timeDelta = datetime.now() - kbur.lastChanged
if timeDelta.seconds > 7200:
#if kvny.lastChanged > kbur.lastChanged:
wthrStation = indigo.devices[204052749]
indigo.variable.updateValue(752974756, "KVNY") # "WeatherCurrentStation"
indigo.server.log("KBUR Time Since Update: "+ str(timeDelta), type="Irrigation:")
#indigo.server.log("KBUR Time Since Update: "+ str(timeDelta.strftime("%H:%M")), type="Irrigation:")
Irrigation: KBUR Time Since Update: 1 day, 0:47:19.431777
dtich wrote:Seems the code for calculating time since update is only within 24 hours, doesn't count more than one day? Currently KBUR is still not updating, but the routine has promoted it to current because the time call is not taking the number of days into account. Any ideas how to get it to include days... ?
This is current:
- Code: Select all
timeDelta = datetime.now() - kbur.lastChanged
if timeDelta.seconds > 7200:
#if kvny.lastChanged > kbur.lastChanged:
wthrStation = indigo.devices[204052749]
indigo.variable.updateValue(752974756, "KVNY") # "WeatherCurrentStation"
indigo.server.log("KBUR Time Since Update: "+ str(timeDelta), type="Irrigation:")
#indigo.server.log("KBUR Time Since Update: "+ str(timeDelta.strftime("%H:%M")), type="Irrigation:")
[Update.]
I did switch back to the logic using simple lastChanged greater than and that has put KVNY back to current as it should be. It also logs this:Irrigation: KBUR Time Since Update: 1 day, 0:47:19.431777
That does work for now, but ultimately would like to be able to keep it to switching when BUR is offline for two hours no matter how many days are also tacked onto that 2 hours LOL.. can't find any explanation for KBUR being down for more than 24 hours now... But it clearly is. Doesn't even show up on the list of current METARS at this point. Odd.
Thanks for any pointers, no rush. Also, the title of this thread is somewhat over-dramatic it seems to me, certainly in my case, so if my comments want to be moved, or the thread re-titled (NOAA Plugin Station Update Issues?)... makes sense to me. 2¢.
if timeDelta.seconds > 7200 or timeDelta.days > 0:
scs wrote:logs sent a couple minutes ago . I sent the 26th and 27th. the 26th is where the logging just stops at 21:16 , and then you can see where I restarted the plugin on the 27th . ... seems to support the idea that it may have hung.
I have a little Fibaro FGK-10X that supports a temp sensor, so that's an option if the NOAA problem continues
I was considering calling the airport and pointing out that I don't feel I'm getting my money's worth for this NOAA weather service, especially considering all the money I'm paying for it
Jan 29, 2022 at 11:53:13 AM
Script address : KBUR
batteryLevel : None
buttonGroupCount : 0
configured : True
description : burbank airport
deviceTypeId : station
displayStateId : temperatureString
displayStateImageSel : TemperatureSensor
displayStateValRaw : 50.0 F (10.0 C)
displayStateValUi : 50.0 F (10.0 C)
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
folderId : 443424329
globalProps : MetaProps : (dict)
com.perceptiveautomation.indigoplugin.NOAAWeather : (dict)
address : KBUR (string)
id : 228772392
lastChanged : 2022-01-28 00:30:07
lastSuccessfulComm : 2022-01-28 00:30:07
model : Weather Station
name : weather station_burbank
ownerProps : com.perceptiveautomation.indigoplugin.NOAAWeather : (dict)
address : KBUR (string)
pluginId : com.perceptiveautomation.indigoplugin.NOAAWeather
pluginProps : emptyDict : (dict)
protocol : Plugin
remoteDisplay : True
sharedProps : com.indigodomo.indigoserver : (dict)
states : States : (dict)
currentCondition : Fair (string)
currentConditionIcon : nskc (string)
dewPointC : -5.6 (string)
dewPointF : 21.9 (string)
dewPointString : 21.9 F (-5.6 C) (string)
heatIndexC : - data unavailable - (string)
heatIndexF : - data unavailable - (string)
heatIndexString : - data unavailable - (string)
humidity : 33 (string)
latitude : 34.19967 (string)
location : Burbank - Bob Hope Airport, CA (string)
longitude : -118.36538 (string)
observationDate : Thu, 27 Jan 2022 23:53:00 -0800 (string)
pressureInches : 30.22 (string)
pressureMillibars : 1022.4 (string)
temperatureC : 10.0 (string)
temperatureF : 50.0 (string)
temperatureString : 50.0 F (10.0 C) (string)
visibility : 10.00 (string)
windDegrees : 20 (string)
windDirection : North (string)
windKnots : 3 (string)
windMPH : 3.5 (string)
windString : North at 3.5 MPH (3 KT) (string)
subModel :
subType :
supportsAllLightsOnOff : False
supportsAllOff : False
supportsStatusRequest : False
version : None
Jan 29, 2022 at 11:53:40 AM
Action Group weather/update vars
Irrigation: KBUR Time Since Update: 1 day, 11:23:33.306442
Irrigation: KBUR Last Obs: Sat, 29 Jan 2022 10:51:00 -0800
cntobsdate = wthrStation.states['observationDate']
#timeDeltaObs = datetime.now() - str(cntobsdate)
indigo.server.log("KBUR Last Obs: "+ str(cntobsdate), type="Irrigation:")
It shows last obs at 0753Z on the 28th, which is almost midnight on the 27th here, as expected by the last comm data in the plugin. So.. what gives?KBUR 280753Z 02003KT 10SM CLR 10/M06 A3022 RMK AO2 SLP224 T01001056 402220056 $
Users browsing this forum: No registered users and 1 guest