LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > Musings on technology, philosophy, and life in the corporate world
User Name
Password

Notices


Hi. I'm jon.404, a Unix/Linux/Database/Openstack/Kubernetes Administrator, AWS/GCP/Azure Engineer, mathematics enthusiast, and amateur philosopher. This is where I rant about that which upsets me, laugh about that which amuses me, and jabber about that which holds my interest most: *nix.
Rate this Entry

Natural light tracking with Home Assistant and Tuya

Posted 08-31-2022 at 05:15 PM by rocket357
Updated 08-31-2022 at 06:25 PM by rocket357 (typo)

I have a few animal breeding projects that my wife and kids are into heavily, and one specific project that's just beginning is Western Hognose Snakes. We have a young male Axanthic Western Hognose that we named Gene (work with me on this, they're pets as well as breeders!). Gene is in a bit of a large enclosure for a snake his size, complete with lots of substrate to rummage around through, live plants, and a few hiding places. He's a super happy snek.

So here's the issue: Western Hognose snakes are diurnal, meaning they're awake during the day. As such, it's recommended to provide them with seasonally appropriate "day" lengths and brightness (not to mention, the live plants need light as well!). A lot of sites recommend having a timer setup to provide 12/12 schedule for most of the year, with as high as 16/8 for summer and 8/16 for winter. This is what I'd set up previously, and this morning the sudden kick-on of Gene's light at 100% brightness woke me up.

As I lay in bed half asleep and half awake, the thought crossed my mind that if the sudden full intensity woke me out of a dead sleep (Gene's enclosure is on my side of the bedroom), what is it doing to Gene? Granted, he spends a significant amount of time buried under substrate, but still...his favorite hiding spot is near the edge of the tank, where he is exposed to light levels outside the tank. I wondered if a more gradual "sunlight-like" curve would be possible...and it dawned on me that Home Assistant's Sun integration provides the sun's elevation at any given time of day based on the server's geographical location.

Alright, now I've got a curve I can work with, and I just need to automate adjusting his lights. The light I'm using to provide "daylight" (he has separate "heat" bulbs) is a Tuya-based smart bulb. From Home Assistant I can set the bulb to a given brightness, color temperature, etc... even actual color if desired (Gene may not approve if his lighting is all purple or the like, though). Tuya is neat, but it goes through a cloud hosted overseas, so there is significant latency involved. To work around that, I installed the Home Assistant Community Store and then through that installed localtuya. localtuya is an interesting codebase that connects to the Tuya cloud and downloads/caches the device keys so Home Assistant can reach out directly to the Tuya device on the local network and control it from a local network connection, negating the massive latency (and sometimes connectivity) issues that hitting the Tuya cloud over the open internet can experience. This increases both the speed and reliabilty of Tuya devices, and even makes it possible to control them if my internet provider is having one of their "routine" outages =) (all of our reptile heat lamps are controlled in this fashion already, so setting this up was very straightforward).

With Gene's "daylight" bulb pulled in via localtuya, and a bit of rescaling maths, I now have Gene's daylight bulb doing it's best impression of the actual seasonally correct and geographically correct daylight intensity and color temperature for my area. In short, it comes on very dimly in the early hours of the morning when the sun comes up, and increases in brightness and temperature over the course of the day, finally scaling back down to 2000K/zero brightness in the hours leading up to sunset. I'll be rolling this out to all of our diurnal reptiles over the next few days.

I also may at some point add in a "rainy day" emulation, but for now I think Gene is going to be happy with his new light environment.

I know I will =)
Posted in Uncategorized
Views 417 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 05:25 PM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration