Getting a Weatherlink device temp into a variable as an int

Posted on
Fri Apr 30, 2021 1:26 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Getting a Weatherlink device temp into a variable as an int

For some reason I’m having an issue getting the temp into a variable as an integer, without any decimal, from my Weatherlink device.
I use images to represent the temp so the decimals keep them from displaying.

I’ve tried the Adaptors plugin and a python script that triggers on any change to the variable but nothing consistently works.
Hoping maybe Weatherlink could have a temp status added that doesn’t have a decimal?

Open to other solutions as well.

Thanks,

Carl

Posted on
Fri Apr 30, 2021 1:29 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Davis Weatherlink Request

As a general principal, I really don't like adding things to my plugins just for UI purposes. I don't understand why you would have any issues doing this with a simple script. Can you post the script you're using and some examples of when it's not working as you want?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Apr 30, 2021 2:35 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Davis Weatherlink Request

This is the script that's triggered on any change to the variable.
Code: Select all
wsTempOut = indigo.variables[1618693284]
intValue = wsTempOut.getValue(int)   # 0 if it can't be converted
indigo.variable.updateValue(1618693284, value=str(intValue))


It works fine when run manually but misses fairly consistently on any change to the variable.
I've also added delays and even run it twice with a delay but nothing works.

Thanks,

Carl

Posted on
Fri Apr 30, 2021 2:59 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Davis Weatherlink Request

Change it so it's called on the device state change, then do the conversion from the device state value to the variable. You can't write to the variable you're reading from, because that's also a change which will fire the trigger again and now you're in a recursive loop.

This was discussed in your previous thread, and you'll note that I was using two different variables there. One for the input "number" and one for the output "string".

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Apr 30, 2021 3:14 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Davis Weatherlink Request

I did try that but will again with a delay.

Thanks,

Carl

Posted on
Fri Apr 30, 2021 3:15 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Davis Weatherlink Request

ckeyes888 wrote:
I did try that but will again with a delay.


If you're not trying to read and write to the same variable, no delay should be needed. And it might be causing other problems.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Apr 30, 2021 5:39 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Davis Weatherlink Request

Ultimately what’s working best is to trigger from the variable with a condition it contain a “.”
Solves the loop issue.

Carl

Posted on
Sat May 01, 2021 11:24 am
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Davis Weatherlink Request

Ugh. Now nothing seems to work. Amazing something so simple could be such a problem.

Carl

Posted on
Sat May 01, 2021 11:30 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Davis Weatherlink Request

Can't help if you don't post the code you're working with. And this really should be in the Python scripting forum, because none of this is specific to the WeatherLink plugin.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun May 02, 2021 9:16 am
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Getting a Weatherlink device temp into a variable as an

How can you be so sure it’s not the plugin?
I’ve used scripts to remove integers from many different sources for many years and have never had an issue.

This is the code I’m using.
Code: Select all
 wsTempOut = indigo.variables[1618693284]
intValue = wsTempOut.getValue(int)
indigo.variable.updateValue(1618693284, value=str(intValue))

It works fine when triggered manually.

Could it be the device or plugin doesn’t change the value smoothly? Possibly with a fast “flicker”.
Something is fooling every trigger I’ve tried on it. I use a bunch more just like it on other devices that never miss.

Thanks,

Carl

Posted on
Sun May 02, 2021 9:32 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Getting a Weatherlink device temp into a variable as an

ckeyes888 wrote:
Code: Select all
 wsTempOut = indigo.variables[1618693284]
intValue = wsTempOut.getValue(int)
indigo.variable.updateValue(1618693284, value=str(intValue))


Carl, I'm assuming that your variable id 1618693284 is being populated by something else. How is that being populated?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun May 02, 2021 10:06 am
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Getting a Weatherlink device temp into a variable as an

wsTempOut is populated by another trigger that just inserts any change in WeatherLink temp into the variable.

Thanks,

Carl

Posted on
Sun May 02, 2021 12:01 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Getting a Weatherlink device temp into a variable as an

ckeyes888 wrote:
wsTempOut is populated by another trigger that just inserts any change in WeatherLink temp into the variable.l


Ok. Is that trigger firing correctly? In other words, whenever the temp state changes on that device the trigger actually fires (you can see firings in the Event Log window).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun May 02, 2021 12:03 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Getting a Weatherlink device temp into a variable as an

Post a screen capture of the trigger definition also please.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun May 02, 2021 2:22 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Getting a Weatherlink device temp into a variable as an

Here’s the trigger to populate the wsTempOut variable.
It works fine....and yes, it shows in the event log.

Edit: One thing I’ve noticed is the script showing in the log has comments that are not in my script.
Code: Select all
 Trigger                         Integer Fix Temp Out Python

# Getting the integer value
intValue = wsTempOut.getValue(int)   # 0 if it can't be converted
intValue = wsTempOut.getValue(int, default=10) # 10 if it can't be converted

indigo.variable.updateValue(1618693284, value=intValue)
   Schedule                        Davis Wind Direction/Gust Text Set Variable (delayed action)
   Schedule                        Integer Fix Temp Out Python

# Getting the integer value
intValue = wsTempOut.getValue(int)   # 0 if it can't be converted
intValue = wsTempOut.getValue(int, default=10) # 10 if it can't be converted

indigo.variable.updateValue(1618693284, value=intValue) (delayed action)

The “# 0 if it can’t be converted” and ‘# 10 if it can’t be converted” aren’t in my script if that means anything.

Carl
Attachments
0E70B9C2-7AAD-4F29-B906-D1ABE2739858.jpeg
0E70B9C2-7AAD-4F29-B906-D1ABE2739858.jpeg (197.94 KiB) Viewed 2302 times

Who is online

Users browsing this forum: No registered users and 8 guests