Jump to content

Photoelectric control of lighting scenes


Culvdave

Recommended Posts

I have several lighting scenes programmed to turn on at specific times relative to sunset. Problem is on cloudy days interior of house get's too dark earlier than programmed times. Is it possible to use some kind of photoelectric cell to control scenes instead of time of day? 

Link to comment

I have several lighting scenes programmed to turn on at specific times relative to sunset. Problem is on cloudy days interior of house get's too dark earlier than programmed times. Is it possible to use some kind of photoelectric cell to control scenes instead of time of day?

Yes. You could connect a sensor to an I/O Linc and add it to your programs.

 

I'm Gary Funk and I wrote this message.

Link to comment

I'm not familiar with a 5-1 sensor, is that an Insteon product?  I do have a spare motion sensor, how would I write the program using that? I would want the scenes to turn off at a specified time.

 

There are a couple of alternatives. Here is a program that uses the dusk sensor in an insteon motion sensor, and checks for dusk as a fall back. Its unlikely, but if the sensor is sensing motion at the same time as the dusk call, it misses it. I also have "Fast on" for a local switch to turn on the associated items. 

 

The sunset - 45 for 45 minutes insures that dark storm system doesn't set it off early, or the occasional eclipse. 

 

Turning them on

Lights on Dusk - [ID 0009][Parent 0006]

If
        (
             From    Sunset  - 45 minutes
             For      45 minutes 
         And Control (Old) 'Yard / Premise Lights / Driveway Motion-Sensor-Dusk.D' is switched On
        )
     Or Time is Sunset  +  4 minutes
     Or 'Kitchen / Back Deck' is switched Fast On
 
Then
        Set Scene 'Yard / Yard and Lamp Security / Yard light - Lanscape Lights ' On
        Wait  32 seconds
        Set Scene 'Yard / Yard and Lamp Security / Yard Lights On' On
 
Else
   - No Actions - (To add one, press 'Action')
 
Turn on yard lights by driveway dusk sensor
The 32 second delay between the landscape lights and everything else is becuase the landscape lights have 30 second delay after powerup
The From / For conditions prevent early turn on by a heavy late afternoon storm


Another way to achieve this, if you have the climate module, and a nearby weather station that reports Light %, that can be used too. 

 

Turning them off

To turn them off, simply have a program at that time that turns them off. 

 

 

 

 

Paul

Link to comment

@builderb - I've been thinking about doing the same thing with Raspi. Can you share more specifics on how you built this and what code you're using on the rpi to update the ISY variable?

 

Thanks,

 

Steve

 

 

Nice!

Can you list the hardware required to do this?

 

 

A photo sensor and a pi. It's very simple. You write the program to set a variable on the ISY when the point changes.

 

Gary Funk

Merry Christmas

So, basically what Gary said. It's nothing terribly complicated. I wired up an old spare Pi to a photoresistor per this Adafruit guide:

https://learn.adafruit.com/basic-resistor-sensor-reading-on-raspberry-pi/basic-photocell-reading

 

Then I modified their Python script that reads the values per the following:

#!/usr/bin/env python

import RPi.GPIO as GPIO, time, os
import httplib2

username='<ISYusername>'
password='<ISYpassword>'
host="http://<XXX.XXX.XXX.XXX>"

rest="/rest/vars/set/"

ISY_Integer = 1
ISY_State = 2
cur_value = ""
isy_var_num = <ISYvar_number>

DEBUG = 1
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

def RCtime (RCpin):
        reading = 0
        GPIO.setup(RCpin, GPIO.OUT)
        GPIO.output(RCpin, GPIO.LOW)
        time.sleep(0.1)

        GPIO.setup(RCpin, GPIO.IN)
        # This takes about 1 millisecond per loop cycle
        while (GPIO.input(RCpin) == GPIO.LOW):
                reading += 1
        return reading

def ISY(mhost,murl,muser,mpass):
                h = httplib2.Http(".cache")
                h.add_credentials(muser, mpass)
                resp, content = h.request(mhost + murl,
                        "GET",
                        headers={'content-type':'text/plain'} )

while True:
        prev_value = cur_value
        cur_value = RCtime(18)

        if cur_value < 1000 and prev_value >= 1000:
#               print("Light")
                value = 1
                r = ISY(host,rest + str(ISY_State) + "/" + str(isy_var_num) + "/" + str(value),username,password)
        elif cur_value >= 1000 and prev_value < 1000:
#               print("Dark")
                value = 0
                r = ISY(host,rest + str(ISY_State) + "/" + str(isy_var_num) + "/" + str(value),username,password)

All I did was replace their loop that constantly printed the value with a loop that checks to see if the value has crossed a numerical threshold. I have defined my threshold as 1000 here. You'll have to adjust yours as necessary to suit your taste. Uncomment the print lines during testing if you want to run the script from the command line. If all is working, you'll see it print Light and Dark as you cover the sensor with your hand.

 

Make it executable, and follow this guide to start this service at boot:

http://raspberrywebserver.com/serveradmin/run-a-script-on-start-up.html

 

If you've got the pi and some wire handy, the sensor and capacitor will set you back a couple bucks. Hope that helps.

Link to comment

So, basically what Gary said. It's nothing terribly complicated. I wired up an old spare Pi to a photoresistor per this Adafruit guide:

https://learn.adafruit.com/basic-resistor-sensor-reading-on-raspberry-pi/basic-photocell-reading

 <code listing snipped>

 

 

Nice! Thanks

I don't know anything about the RPi header pins.

 

So you basically just.

Create an RC charge circuit using the photocell and small cap.

Turn the pin into an output

Short the cap to ground

Turn the pin into an input

Time the charging until the digital input flips high.

Massage the count (if desired)

Report the result to ISY

Link to comment

Nice! Thanks

I don't know anything about the RPi header pins.

 

So you basically just.

Create an RC charge circuit using the photocell and small cap.

Turn the pin into an output

Short the cap to ground

Turn the pin into an input

Time the charging until the digital input flips high.

Massage the count (if desired)

Report the result to ISY

Yep! Crude, but effective.
Link to comment

Photocell relay connected to the sense terminals of an I/O Linc can trigger a program. Nothing sophisticated, just a simple solution.

I keep running into that statement that you can hook an analogue device into those terminals. I have never followed it up though.

 

I have not seen anything in software that can support the analogue levels. Can you elaborate somewhat on that technique if you have any knowledge/experience with it?

 

Is it just a binary input, does it have a settable trigger point?

Or is it full analogue = creating a full analogue output level parameter?

Does ISY syupport it?

Link to comment

I've had to couple it with a variable resistor to set the right point trigger point, but it is binary on/off for sure.

 

I keep running into that statement that you can hook an analogue device into those terminals. I have never followed it up though.

I have not seen anything in software that can support the analogue levels. Can you elaborate somewhat on that technique if you have any knowledge/experience with it?

Is it just a binary input, does it have a settable trigger point?
Or is it full analogue = creating a full analogue output level parameter?
Does ISY syupport it?

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...