2015-07-27, 07:05
Hi everyone, new comer from the MCE world, and have been very impressed with kodi and how I can integrate it with my home automation.
Couple of quick questions though.
I know nothing of python but have cobbled together a few scripts that seem to be working for my lighting needs that can differentiate between night and day. BUT FOR THE LIFE OF ME I CANNOT GET RESUME TO WORK!!!! I was up until 4am the other night trying to make it do what I wanted.
Does kodi pass a media type argument on resume? After the amount of time I have spent on this I'm thinking its a no.
Basically when I watch a movie at night and I pause the lights behind my couch turn on. When I resume my hope would be that for a movie the light would turn back off, whereas for just regular tv watching I want all my lights to stay on. Which it currently doesn't do no matter what arguments I set.
Thanks in advance for any help or pointers offered.
Couple of quick questions though.
I know nothing of python but have cobbled together a few scripts that seem to be working for my lighting needs that can differentiate between night and day. BUT FOR THE LIFE OF ME I CANNOT GET RESUME TO WORK!!!! I was up until 4am the other night trying to make it do what I wanted.
Does kodi pass a media type argument on resume? After the amount of time I have spent on this I'm thinking its a no.
Basically when I watch a movie at night and I pause the lights behind my couch turn on. When I resume my hope would be that for a movie the light would turn back off, whereas for just regular tv watching I want all my lights to stay on. Which it currently doesn't do no matter what arguments I set.
Code:
import xbmc
import urllib2
import datetime
DAY, NIGHT = 1, 2
def check_time(time_to_check, on_time, off_time):
if on_time > off_time:
if time_to_check > on_time or time_to_check < off_time:
return NIGHT, True
elif on_time > off_time:
if time_to_check > on_time and time_to_check < off_time:
return DAY, True
elif time_to_check == on_time:
return None, True
return None, False
on_time = datetime.time(18,00)
off_time = datetime.time(04,00)
timenow = datetime.datetime.now().time()
current_time = datetime.datetime.now().time()
when, matching = check_time(current_time, on_time, off_time)
if matching:
if when == NIGHT:
if 'movie' in sys.argv[1]:
urllib2.urlopen('insert lighting url here')
if 'episode' in sys.argv[1]:
urllib2.urlopen('insert lighting url here')
urllib2.urlopen('insert lighting url here')
Thanks in advance for any help or pointers offered.