light nerdery, 2

Screen Shot 2015-11-29 at 11.36.16 PM

So after a bunch of fighting with trying to directly build a menu then giving up and using a simplified toolkit, my little weather-based light control script now manifests a menubar icon, and a list of all of your scenes. At some point in the near future I will package it up as an .app, and add in dialogue boxes to enter your LIFX and forecast.io API keys. And then it will be pretty much done.

At some point in the further future I may want to also add the ability to actually set up what scenes it chooses between based on temperature ranges, but that’s a complicated beast involving designing and using a UI. And this is just a quick little Python hack.

edit. Now it’s on Github if anyone feels like using it or adding to it.

light nerdery

I just spent about five hours kludging together a little Python script to change the color of my foyer’s light based on the temperature. I already had that happening via If This Then That, but there were some limitations – it didn’t work well with me also wanting to change the light to a dim red in the evening.

So I dove into the mysteries of the LIFX web API, and the forecast.io web API, and wrote something. Now, my foyer will change between four different colors based on the temperature (blue/purple/yellow/nearly white) between the hours of 8am and 8:30pm, and switch to a dim red outside of those hours. There’s also a temperature offset based on the next hour’s conditions; precipitation or high winds lower the effective a bit so I’m not out there being miserable when it’s near the bottom of a temperature range and wind or rain is making it feel chillier.

# peggy's little foyer-light controller
#
# selects from a set of lifx scenes based on the temperature from forecast.io
#

import requests
import sys
import math
import time

lifxToken = 'your token goes here'
# generate your token at https://cloud.lifx.com/settings

darkSkiesToken = 'your token goes here'
# generate your token at https://developer.forecast.io

#
# desired temperature ranges for scenes you've set up via the lifx app
# 
choices = [
 {'scene':'Foyer Cold', 'lower':0-float("inf"), 'upper':54, 'note':'Wear a heavy coat, miss dragon.'},
 {'scene':'Foyer Chilly', 'lower':55, 'upper':66, 'note':'Light coat. Or sweater. Or something.'},
 {'scene':'Foyer Hot', 'lower':67, 'upper':74, 'note':'As long as your sin globes are covered, anything goes.'},
 {'scene':'Foyer Really Hot', 'lower':75, 'upper':float("inf"), 'note':'It is HOT. Take a parasol or something.'},
]

nighttime = {
 'scene':'Foyer Evening',
 'nightBegins': 20.5, # 24-hour decimal time. 8:30PM = 20.5.
 'nightEnds': 8.0, # 24-hour decimal time. 8 AM = 8.0.
}

# temperature offsets for various conditions
# as defined by forecast.io's 'icon' property of the forecast
offsets = {
 'clear-day':0,
 'clear-night':0,
 'rain':-10,
 'snow':-10,
 'sleet':-10,
 'wind':-5,
 'fog':0,
 'cloudy':-5,
 'partly-cloudy-day':-5,
 'partly-cloudy-night':-5,
}

latitude = '47.6659248'
longitude = '-122.3181908'
# where are you?
# really this should talk to OSX's location manager
# but that starts to look like work

repeatDelay = 5*60 # delay between repetitions, in seconds
 # lifx' api throttles you to about once a minute
 # forecast.io throttles to 1000 requests/day (about one every 1.4 min)

#
# picks a scene based on the forecast
#
def ChooseScene (choices, offsets, nighttime, forecast):
 # there should be some logic here to check the time
 # and if it's earlier or later than certain times
 # we cancel out and just display the nocturnal light
 
 now = time.localtime()
 now = now.tm_hour+((1.0/60)*now.tm_min)
 if (now < nighttime['nightEnds']) or (now > nighttime['nightBegins']):
 print "it's nighttime! the time is now ",now
 return nighttime['scene']
 
 # figures out temperature offset based on the next hour's condition
 condition = forecast['hourly']['data'][0]['icon']
 offset = offsets[condition]
 
 temperature = round(forecast['hourly']['data'][0]['temperature']+offset)
 print 'current temperature:',temperature
 for choice in choices:
 if temperature > choice['lower'] and temperature < choice['upper']:
 print choice['note']
 return choice['scene']


#
# contacts LIFX and acquires a list of scenes
#
def GetScenes(token):
 headers = {
 "Authorization": "Bearer %s" % token,
 }
 
 authorization = requests.get('https://api.lifx.com/v1/lights/all', headers=headers)
 
 if authorization.status_code != 200:
 print "\ninvalid authorization, maybe check your token?\n"
 sys.exit()
 
 scenerequest = requests.get('https://api.lifx.com/v1/scenes', headers=headers).json()
 
 # I am sure there is a much more pythonic way to do this. Works though.
 scenes = {}
 for scene in scenerequest:
 scenes[scene['name']] = scene['uuid'].encode('ascii')
 
 return scenes

#
# sets a lifx scene
#
def SetScene(uuid,token):
 headers = {
 "Authorization": "Bearer %s" % token,
 "duration": 60*5,
 }
 
 result = requests.put('https://api.lifx.com/v1/scenes/scene_id:'+uuid+'/activate', headers=headers)
 return result

#
# acquires a forecast from forecast.io
#
def GetForecast(latitude, longitude, token):
 forecast = requests.get('https://api.forecast.io/forecast/'+token+'/'+latitude+','+longitude).json()
 return forecast

#
# all functions are defined, time to do it to it!
#
lastScene = ''
scenes = GetScenes(lifxToken)

while True:
 forecast = GetForecast(latitude, longitude, darkSkiesToken)
 whichScene = ChooseScene(choices, offsets, nighttime, forecast)
 if lastScene == whichScene:
 print "no need to change the scene right now."
 else:
 print 'setting scene:'+whichScene
 SetScene(scenes[whichScene],lifxToken)
 lastScene = whichScene
 print "waiting a bit..."
 time.sleep(repeatDelay)

# fail silently because i'm a bad girl

…I really should get some kind of code formatting plugin for this blog someday.

BLACK FRIDAY SALE

I have re-opened my store with SPECIAL BLACK FRIDAY/CYBER MONDAY PRICES! Enjoy!

a holiday avoided

So Thanksgiving was pretty good: I wandered out in the afternoon and hung out in the park with a book, then Nick came over and we marathoned Gravity Falls. I've now seen every episode extant, and am waiting for the final one like everyone else. No mandatory dinner with all the relatives or anything like that.

Nick is now puttering around the bathroom debating if he's going to go back home for the Thanksgiving thing they do there. I'm debating going to a thing a friend does. Might just stay at home and enjoy another fairly quiet day…

Also I should really open up my store for a few days for a SPECIAL BLACK FRIDAY SALE!!!!!1!!1!!!.

Skeen: the verdict.

 

So. The Skeen trilogy by Jo Clayton turned out to be pretty decent. My opinion of it is probably a bit colored by nostalgia, but overall I feel like it was a fun bit of SF, told with competence, charm, and flair.

I also realized that it is pretty much right in the middle of my sweet spot. It contains:

  • Charming rogues.
  • Shape shifters.
  • A travelogue across a full of strange creatures.
  • A lady protagonist.
  • Space opera mixed with fantasy.
  • A subliminal hint of queerness.

Honestly, I'm primed to like a book with just three of these. Skeen delivers on all of them. The lady protagonist is a charming rogue named Skeen, whose jaundiced but hopeful view permeates the whole story. The shape shifter is a lady named Telka, who is her adventuring companion for almost the entire book. The crew of hangers-on, assistants, allies, and obligations Skeen collects through the first two books include a quartet of elfin teenage boys with sensory cillia for hair, a squat, solid scholar who reminds Skeen uncomfortably of her SO, another shifter whose default form is something insectile that I tend to think of as somewhere between an anthropomorphic spider and an anthropomorphic mantis, a small boy who can spit poison and is the last of his tribe, that boy's pet frilled lizard, and a lady flying squirrel who is one of the ancients who created the Gate to the semi-medieval planet this all happens on. Then Skeen gets back to the normal world, with nobody but the flying squirrel and the shifter, and we meet a whole new crew of weirdos: Skeen's squat, solid, ex-acrobatic partner in crime (and bed) Tibo, her charming and feminine spaceship Picafrey, a pair of fellow smugglers named Hopeless and the Virgin (two nearly identical black ladies, the former being two meters tall, the latter only one, and mute save for a bunch of mysterious Voices that follow her around), a young scoundrel who knows the way to the planet of the ancient flying squirrels… Taverns full of even weirder aliens, hopping from one planet to another. It's just a whole lot of fun.

 

(The queerness? Skeen and the scholar share some no-limits S&M sex a few times – it's never described but it's clearly both consensual and really hot, albeit rather closer to the edge than either is really comfortable with. There's a few other bits that I got a feeling of possible non-het sex happening outside the narrative gaze from, though it may have been wistful thinking.)

 

Is it great art? Nah. It's a fun story, charmingly told. The second and third books both drag a little at the end; it's clear that Skeen's obligations, and Clayton's narrative obligations, have grown larger than either of them is quite comfortable with, and Clayton becomes more prone to resort to leaning against the fourth wall and saying, look, if I continue at the level of detail I wrote the beginning at then we'll be here for twenty books, and neither of that really wants that, do we? This and that happens, if you really need more detail imagine it yourself, I'm skipping ahead to the next good bit. Which to be honest was not something I complained about at all. It's like, did anyone criticize Star Wars for not showing the trade negotiations? You're here for the pulp adventure, not the politics.

 

If you want to give it a shot, it shouldn't be too hard to find used copies online. You could probably find illegal e-books, too. I didn't find any sites I'd quite trust but you might be better at finding piles of book downloads. Sadly you can't buy an e-book; Clayton died before that became a thing, and didn't seem to leave any heirs interested in making a few bucks off these, or any of the thirty-odd books she wrote over her lifetime. I've got four more of them either on my coffee table or in the mail as I speak: the first four books of the Diadem series, her first stuff. I'm looking forwards to them.

I almost never bother drawing characters from books I like, and I liked it enough to actually do that. I might even draw a few more, and do something like finished images of them all.

 

Fallout 4

Kerri: “so what’s the Fallout 4 verdict?”

My response:

It sure is another open-world game from Bethesda. You’ll never be shocked or amazed while playing it, but there sure are a lot of side-quests and sub-systems to distract you and fill up your winter hours.

And the characters are slightly less robotic than usual. They actually make attempts to emote instead of standing there like plastic automatons delivering woodenly-acted tapes. Still ain’t gonna win an Oscar or anything for its acting.It is a huge pile of okayness that I will probably put hours into, finish the main quest, snark about it, and do about a third of the sidequests of. And every moment I run out of action points and have to do the realtime combat up close, I’ll wish I was playing Bloodborne instead, because holy crap the weapon swap method is so awkward.

I’m also just never much of a fan of the post-apocalypse setting tbh. I keep on looking at its dingy, run-down future and wishing I was playing a similar free-form game set in a bright, happy, optimistic future. Something best summed up as “GTA Coruscant”.

(There was an actual open-world rpg set among the scumlings of Coruscant in the works for a while, but it got canned despite looking pretty promising. That makes me sad every time I think about it. But it doesn’t have to actually be the Star Wars license; I’d be happy with any giant future city full of aircars and ray-throwers and aliens and a customizable PC and sidequests.)

the dream of most of the people in my life whose death affected me in any way

Wow. Lots of dead people in my dreams last night. Kara, Marie-Jeanne, and Ricky.

Ricky revealed to me that he had faked his death, and was hanging around being mysterious and working on an indy video game and going slightly crazy from solitude. Though the huge scars on his wrists suggested to me that no, he really hadn't faked it at all.

I don't remember what the hell Kara or Marie-Jeanne were doing in my dreams. Something about a song and traveling with Kara?

If Russell had shown up, that would have been pretty much everyone whose death really affected me. What the heck.

oh winter

Last night, I stayed up until 6AM playing Fallout 4. I slept late, unsurprisingly.

I finally crawled out of bed just now, at almost 4pm. Stuck my nose outside and was greeted by a blast of 48º wind.

 

Hello, winter. I didn’t miss you.

 

removing depressing mundanities

Today, I cleaned my toilet. It’s been needing it for… several months, now. It was a bit meh in the summer when I went down to New Orleans to be by my mother’s deathbed, and by the time I got back it had matured into some dark spots on the inner lid that helped refresh the dark spots in the bowl far too quickly.

This was, of course, pretty depressing to see every time I went to the bathroom. But I was also depressed about my mom’s death, and pretty soon I was depressed due to it being winter, as well.

Every time I’d go to the bathroom seeing the state of my toilet would make me feel just that tiny bit shittier. But I could never wind up the mental energy to just fucking clean the thing – I’d have to figure out how to remove the lid so I could put it in the tub with something soaking into the top for a while. It felt complicated. Just thinking about trying to figure out how to do this was depressing.

IMG_1977.jpg

This is what depression looks like.

I finally did it today. And made a stab at the clean laundry pile that’s been sitting next to my bed for about as long. I feel a lot better about my apartment now.

I’m sure I’ll still be mopey and sad. I’ve got two very good reasons to. But at least I’ll have one less stupid fucking household chore gnawing at the back of my head, making me a little bit sadder every time I tend to a fundamental bodily need.

I feel like if I get nothing else today, cleaning my fucking toilet is still a major accomplishment. Dealing with laundry on top of that? I’m winning at life.

some black dragon

Today was a special day on my calendar. Peganthyrus' Birthday. Twenty years ago, one of the wizzes on Furrymuck @newchar'ed her for me. What started as kind of a joke became an identity that would end up being all-encompassing for me; when I transitioned, I tried a few names, but it was pretty inevitable that I'd settle on a name that shortened to Peggy, just like hers did.

I never noted the exact day I decided to start transitioning. So I can't celebrate that day like some people do. It was somewhere in the end of summer around 2001-4. But I can log onto Furrymuck and type “examine me” to get a solid date on creating the first female identity I'd spend time as. And that's good enough.

I don't make a big deal out of the day. Ever since my father died on my twelfth birthday, birthdays lost their magic for me. I tried doing something for Peggy's Birthday a few times but my heart was never in it.

Anyway. Twenty years ago, I started pretending to be a black dragon lady on the Internet. Which eventually lead to me realizing I was much more comfortable in a female identity, and even more eventually starting to do something about that.

(And I must confess that I feel faintly annoyed that the day before is now the Transgender Day Of Rememberance. Yay! Let's think about all the dead trans people the day before the day I pegged as my own Trans Anniversary Day! Because even after fleeing from my original birthday after it became the day I was plunged into a twenty-year-long depression when my father died on it, I still have to think about death on the new one. THANKS EVERYONE. Not that this spoiled any major party or anything, I spent the day mostly just hiding in the living room playing Fallout 4.)