Python access to the Forecast device

To a blind optimist, an optimistic realist must seem like an Accursed Cynic.
pnm
Posts: 59
Joined: Wed Dec 03, 2014 7:43 am
Location: Yorkshire, UK

Python access to the Forecast device

Post by pnm »

I've created a day zero forecast device called WeatherToday which appears to be working. I can't get the syntax right to get the max temperature in a script.

I would have thought it would be indigo.devices["WeatherToday"].tempmax but its not.

What is the correct syntax?
User avatar
racarter
Posts: 490
Joined: Sat Jun 18, 2016 4:23 am
Location: North Yorkshire, UK
Contact:

Re: Python access to the Forecast device

Post by racarter »

Code: Select all

weather = indigo.devices[12345678]
value_you_want = weather.states["tempmax"]
pnm
Posts: 59
Joined: Wed Dec 03, 2014 7:43 am
Location: Yorkshire, UK

Re: Python access to the Forecast device

Post by pnm »

Thanks
pnm
Posts: 59
Joined: Wed Dec 03, 2014 7:43 am
Location: Yorkshire, UK

Re: Python access to the Forecast device

Post by pnm »

I've setup two triggers on the Maximum Temperature so set and unset a boolean variable, but they don't appear to be firing even though tempmax is over 20c.

Have I done something wrong?
Attachments
Screenshot 2024-05-11 185601.png
Screenshot 2024-05-11 185601.png (15.51 KiB) Viewed 1077 times
Screenshot 2024-05-11 185105.png
Screenshot 2024-05-11 185105.png (13.61 KiB) Viewed 1081 times
User avatar
kw123
Posts: 8408
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: Python access to the Forecast device

Post by kw123 »

A I would not use a . in a name. It has a special function in python. It will likely work but …
Use a _ instead.

Your trigger is „becomes“ not „is“
I guess you need to wait until it goes from 17 to 18

Or you set it to 20 to make it happen earlier


Sent from my iPhone using Tapatalk
pnm
Posts: 59
Joined: Wed Dec 03, 2014 7:43 am
Location: Yorkshire, UK

Re: Python access to the Forecast device

Post by pnm »

Its obviously passed through 18 to get to 20, but the variable is still false. If I run the trigger manually it gets set to true so the action part works. I'm not sure how to debug this now.
User avatar
kw123
Posts: 8408
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: Python access to the Forecast device

Post by kw123 »

When did it pass through 18. today ? Only at that point in time when it goes through that value it triggers.


Sent from my iPhone using Tapatalk
pnm
Posts: 59
Joined: Wed Dec 03, 2014 7:43 am
Location: Yorkshire, UK

Re: Python access to the Forecast device

Post by pnm »

I can't tell at the moment, I'm now sending myself an email with the variable value and the forecast temperature so I'll know when it passes back as the value is now true having been set manually.
User avatar
kw123
Posts: 8408
Joined: Sun May 12, 2013 4:44 pm
Location: Dallas, TX
Contact:

Re: Python access to the Forecast device

Post by kw123 »

The plugin indigo utilities has a menu item that lets you query the sql db. Then you can see when states , variables change / have changed


Sent from my iPhone using Tapatalk
User avatar
FlyingDiver
Posts: 7287
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Python access to the Forecast device

Post by FlyingDiver »

pnm wrote:I can't tell at the moment, I'm now sending myself an email with the variable value and the forecast temperature so I'll know when it passes back as the value is now true having been set manually.
An alternative is to create a scheduled event (run every minute or so) that has a conditional to see if the temp is above your limit.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Post Reply

Return to “Perry the Cynic”