NOAA Plugin failing
- jay (support)
- Site Admin
- Posts: 19232
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: NOAA Plugin failing
@dtich, KBUR hasn't updated since late last night - it's definitely down for some reason.
Re: NOAA Plugin failing
i see this. and of course no one is answering at the local nws/noaa office. ever. so i have no idea the issue and when it might be resolved for good.
so. i should switch to another station. kvny is similar in forecast and conditions usually. not very far.
can you help me with the python syntax for the action to insert variable into indigo var - at the moment i do it with insert device state into var action pulldown, but if i'm going to switch stations back and forth i'd rather do a script and possibly automate it, like if no update in values here, get values from other station temporarily kinda thing. i'll work on that, but if you can start me with the syntax for, say:
so. i should switch to another station. kvny is similar in forecast and conditions usually. not very far.
can you help me with the python syntax for the action to insert variable into indigo var - at the moment i do it with insert device state into var action pulldown, but if i'm going to switch stations back and forth i'd rather do a script and possibly automate it, like if no update in values here, get values from other station temporarily kinda thing. i'll work on that, but if you can start me with the syntax for, say:
starting to cobble together in babytalkpy. thoughts appreciatedinsert state (temperaturef) for device "weather station_kbur" into variable: weathercurrenttemp
Code: Select all
##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))
- jay (support)
- Site Admin
- Posts: 19232
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: NOAA Plugin failing
The variable updates in that script look fine. One small issue: lastChanged is a device property, not a state. Corrected script:
Code: Select all
##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))
Re: NOAA Plugin failing
learning!
this is throwing syntax err:
should it do it with actual vars, not temps?
like:
if indigo.devices.lastChanged[228772392] > ... ?
or, hasattr()?
thx!
this is throwing syntax err:
Code: Select all
if kbur.lastChanged > kvny.lastChangedlike:
if indigo.devices.lastChanged[228772392] > ... ?
or, hasattr()?
thx!
Re: NOAA Plugin failing
nope. it was colon missing
derp
Re: NOAA Plugin failing
added few more lines to indicate selected station. now have the system select among two or three nearby stations whichever is latest update, then displays which one is selected for calculations (currently KVNY) and a nearby one for ref (currently KUSC). feel more secure than relying on one station.. esp given how bloody unreliable they seem to be now.
thanks for help jay.
thanks for help jay.
- Attachments
-
- Screen Shot 2022-01-28 at 3.24.06 PM.jpg (194.87 KiB) Viewed 3908 times
Re: NOAA Plugin failing
Jay, can you show me a line that compares lastChanged to currentDateTime, like, if lastChanged is more than 60mins ago, or 120mins ago?
might want to do it that way instead at some point.
thx
looking at the dox, is it something like this?:
from datetime import datetime
timeDelta = datetime.now() - kbur.lastChanged
if timeDelta.minutes > 60:
******
EDIT: ok, so i'm here:
gives me:
i can prob live with that. but, in case i wanted to round the seconds, or just do hours:mins.. how i do that?
thx!
might want to do it that way instead at some point.
thx
looking at the dox, is it something like this?:
from datetime import datetime
timeDelta = datetime.now() - kbur.lastChanged
if timeDelta.minutes > 60:
******
EDIT: ok, so i'm here:
Code: Select all
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:")
is that hours:mins:seconds?Jan 28, 2022 at 3:44:07 PM
Irrigation: KBUR Time Since Update: 15:14:00.498093
i can prob live with that. but, in case i wanted to round the seconds, or just do hours:mins.. how i do that?
- jay (support)
- Site Admin
- Posts: 19232
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: NOAA Plugin failing
Sure:
strftime is a cool function with lots of options.
Code: Select all
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:")Re: NOAA Plugin failing
ahhh yes. that is a handy function.
this:
is giving me err:
this:
Code: Select all
indigo.server.log("KBUR Time Since Update: "+ str(timeDelta.strftime("%H:%M")), type="Irrigation:")
doesn't like my var. does it only work on an actual datetime return? i tried several other arrangements and some other vars, no joy.AttributeError: 'datetime.timedelta' object has no attribute 'strftime'
Re: NOAA Plugin failing
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:
[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:
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¢.
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:")
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:
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.Irrigation: KBUR Time Since Update: 1 day, 0:47:19.431777
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¢.
Re: NOAA Plugin failing
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
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
Indigo 2025.1 w/ Insteon and Z-Wave lights and outlets
Security integration.
Energy monitoring
Security integration.
Energy monitoring
- jay (support)
- Site Admin
- Posts: 19232
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: NOAA Plugin failing
timedelta objects have 3 parts to them: days, seconds, and microseconds. So, you probably want something like this: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:
[Update.]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:")
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:
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.Irrigation: KBUR Time Since Update: 1 day, 0:47:19.431777
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¢.
Code: Select all
if timeDelta.seconds > 7200 or timeDelta.days > 0:Re: NOAA Plugin failing
yup, perfect, thx jay, much appreciated
- jay (support)
- Site Admin
- Posts: 19232
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: NOAA Plugin failing
Replied to your email.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
Re: NOAA Plugin failing
IGNORE THIS POST PLS. I'LL KEEP IT POSTED FOR MY PERSONAL SHAME
So, explain me this one...:
Here's the script lines that log the obs string:
Huh?
This is the latest and last METAR from this station according to NOAA. It's so old it does not show up on aggregated current obs tables.
Thx!
OH. Such a blunder.
Sorry guys. I realized just now that my var is set to the current one in the script, which at this point would be VNY.. so that explains the issue. So sorry for the panic. LOL
So, explain me this one...:
This shows a device props print out followed by a script run that logs the time delta for last change, and also the last observation date from the props/states.. but, the state in the device dump shows two days ago as expected, and the log shows... about half hour ago...?? Where is this coming from?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
Here's the script lines that log the obs string:
Code: Select all
cntobsdate = wthrStation.states['observationDate']
#timeDeltaObs = datetime.now() - str(cntobsdate)
indigo.server.log("KBUR Last Obs: "+ str(cntobsdate), type="Irrigation:")
This is the latest and last METAR from this station according to NOAA. It's so old it does not show up on aggregated current obs tables.
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 $
Thx!
OH. Such a blunder.
Sorry guys. I realized just now that my var is set to the current one in the script, which at this point would be VNY.. so that explains the issue. So sorry for the panic. LOL
Last edited by dtich on Sat Jan 29, 2022 2:25 pm, edited 2 times in total.