I see where you’re going now. Not sure it’d produce the effect you want but… buckle up 'cause here we go!
The available TWC data doesn’t tell us the type of cloud cover. 100% cumulonimbus is going to have a different impact to our lighting needs than 100% altostratus. In some instances, cloud cover can actually increase the ambient light level such as thunderstorm to the west reflecting light in the morning. All we know is the percentage of cloud cover.
Also, the TWC data cannot be used as a trigger:
It is unfortunate, but a weather alert cannot be used as a trigger. To get alerts for your area, you can program a piston to periodically make a query. (mine is set to run every 15 minutes, but other triggers can work as well, such as right before you go to work) Please program strategically so we don’t hammer the weather server too frequently. Any more often than 4 times an hour is a waste of resources and pointless for alerts. We don’t want to encourage SmartThings to start charging us for this data. (since they are billed for each query)
There’s no way to trigger a lighting event based on a weather alert. Granted, cloud cover isn’t a weather alert but the concept is the same, we can’t adjust the lights because the clouds are rolling in. If that’s what you’re after, getting a sensor that measures lux is the way to go. While we could set up a polling loop to get the current cloud cover condition, that is very costly from a resource perspective. I wouldn’t set this up to check the current conditions every 15 minutes.
The best we can do is to use the $twcweather.conditions.cloudCoverPhrase
variable to get the forecasted cloud cover when a lighting event is triggered and adjust based on that.
Assuming 100% cloud cover is “dark” and 0% cloud cover is “light” we can use the forecasted conditions (they update twice a day) to create the adjustment factor you seek. We can adjust both the day_level
and twilight_level
based on the percentage of cloud cover. The night_level
is our absolute lowest setting. Once night hits, we wouldn’t need to make any adjustments based on cloud cover.
Here’s a chart showing the adjustment:
Examples:
- If we normally set the daytime lights to 90% of full, we would set them to 65% of full if there was a prediction for 50% cloud cover.
- If we normally set the daytime lights to 90% of full, we would set them to 87% of full if there was a prediction for 10% cloud cover.
- If we normally set the twilight levels to 40% of full, we would set them to the default night level (10%) if there was a prediction for 100% cloud cover. This presumes the cloud cover makes the ambient light the same as night since the clouds are obscuring any sunlight and moonlight.
Here’s an updated piston that has the adjustment ready to go: r3y84
If you wanted a less dramatic change, you could adjust the $twcweather.forecast.daypart[0].cloudCover[x]
values by dividing them by two (or three) which would cut the effect proportionally.
I hope this is helpful. Let me know if you give it a try and it does what you’re after. As always, YMMV.