Skip to content

node-RED node that determines blind position based on the position of the sun and climatic conditions

License

Notifications You must be signed in to change notification settings

szurr/node-red-contrib-blindcontroller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-red-contrib-blindcontroller

A collection of Node-RED nodes that can be used to automate the control of household roller blinds based on the current position of the sun.

Install

Run the following command in the root directory of your Node-RED install

npm install node-red-contrib-blindcontroller

Sun Position

Sun Position

This node calculates the position of the sun at a given geo location.
It is configured with the following properties:

  • lat: latitude of the location
  • lon: longitude of the location
  • start: time of day that constitutes the start of daylight hours
  • end: time of day that constitutes the end of daylight hours

This node can optionally receive a time via an input message containing msg.time conforming to Javascript Date object, otherwise it will use the current time.

This node emits a msg.payload with the following properties:

  • sunInSky: boolean value indicating whether it is currently considered daylight hours
  • altitude: altitude of the sun above the horizon in degrees
  • azimuth: azimuth of the sun in degrees, where 0 is North
  • altitudeRadians: altitude of the sun above the horizon in radians
  • azimuthRadians: azimuth of the sun in radians, where 0 is South, a positive value is in the west and negative value in the east

The node sets msg.location with the coordinates of the location and msg.topic to "sun".

The node also reports its status within the Node-RED flow editor, using colour to indicate whether it is currently considered daylight hours.

Blind Controller

Blind Controller

This node calculates the appropriate blind position to restrict or maximise direct sunlight through the associated window.

It is configured with the following properties:

  • channel: identifier of the blind - which is used in the emitted msg.payload
  • mode: mode of control
    • Summer: constrains the extent to which direct sunlight is allowed to enter the room
    • Winter: maximises the amount of direct sunlight allowed to enter the room
  • orientation: the bearing representing the perpendicular to the of the window
  • negative offset: (optional) anti-clockwise offset from orientation for determination of whether the sun is coming through window
  • positive offset: (optional) clockwise offset from orientation for determination of whether the sun is coming through window
  • top: measurement from the floor to top of the window covered by the blind
  • bottom: measurement from the floor to bottom of the window covered by the blind
  • depth: (optional) the extent to which direct sunlight is to be allowed into the room through the window, defined as a length on the floor. (Only relevant in Summer mode.)
  • altitude threshold: (optional) minimum altitude of the sun for determination of blind position
  • increment: the degree to which the blind position can be controlled
  • max open: (optional) the maximum extent the blind is allowed to be opened during daylight hours. Defaults to 0.
  • max closed: (optional) the maximum extent the blind is allowed to be closed during daylight hours. Defaults to 100.
  • temperature threshold: (optional) temperature at which the blind will be fully closed while the sun is in the window. This setting overrides altitudethreshold and depth in the calculation
  • clouds threshold: (optional) maximum percentage of sky occluded by clouds for the calculation to be performed
  • night position: (optional) the position of the blind outside of daylight hours. Defaults to 100.

The calculation requires the output of the Sun Position Node. This can be supplemented with current weather conditions, such as that from forecastio or weather underground. msg.topic should be set to weather, and msg.payload either or both of the following properties:

  • maxtemp: the forecasted maximum temperature for the day;
  • clouds: A numerical value between 0 and 1 (inclusive) representing the percentage of sky occluded by clouds. A value of 0 corresponds to clear sky, 0.4 to scattered clouds, 0.75 to broken cloud cover, and 1 to completely overcast skies.

In Summer mode, the node calculates the appropriate blind position to restrict the amount of direct sunlight entering the room. This calculation includes:

  • determination of whether direct sunlight is entering the room based on the orientation of the blind and the azimuth of the sun - taking into account the negative and positive offset properties; and sunInWindow
  • dimensions of the window and the current altitude of the sun. sunInRoom
  • consideration of weather conditions against defined thresholds

In Winter mode, the node calculates the appropriate blind position to maximise the amount of direct sunlight entering the room. This calculation is based on whether direct sunlight is entering the room based on the orientation of the blind and the azimuth of the sun - taking into account the negative and positive offset properties. When the sun is in the window the blind will positioned in the max open setting, otherwise it will be positioned in the max closed setting.

In the event the node determines a blind position change is required, it will emit a msg.payload with the properties of the blind including:

  • blindPosition: the new position of the blind
  • blindPositionReasonCode: code of rationale of the new position
    • 01 - Manually set
    • 02 - Sun below horizon
    • 03 - Sun below altitude threshold
    • 04 - Sun not in window
    • 05 - Sun in window
    • 06 - Overcast conditions
    • 07 - Temperature forecast above threshold
  • blindPositionReasonDesc: description of rationale of the new position (as above)

In addition, msg.data includes information useful for monitoring:

  • altitude: altitude of the sun in degrees
  • azimuth: azimuth of the sun in degrees
  • sunInWindow: boolean value indicating whether direct sunlight is entering the room based on the orientation of the blind and the azimuth of the sun - taking into account the negative and positive offset properties

msg.topic is set to "blind".

The node also reports its status within the Node-RED flow editor:

  • colour indicates whether it is currently considered daylight hours;
  • shape indicates whether the blind is fully closed or not;
  • text reports current blind position.

Multi Blind Controller

Multi Blind Controller

This node calculates the appropriate blind position to restrict direct sunlight through a number of windows. This node processes three types of input messages:

  • blind configuration where msg.topic equals blind, and msg.payload contains the following properties:
    • channel
    • mode
    • orientation
    • noffset
    • poffset
    • top
    • bottom
    • depth
    • altitudethreshold (optional)
    • increment
    • max open (optional)
    • max closed (optional)
    • temperaturethreshold (optional)
    • cloudsthreshold (optional)
    • night position (optional)
  • the output of the Sun Position Node;
  • current weather conditions, such as that from forecastio or weather underground. msg.topic should be set to weather, and msg.payload either or both of the following properties:
    • maxtemp
    • clouds
  • a specified blind position, which will remain in effect for 2 hours

When processing either a Sun Position or Weather message, the blind position calculation is performed for each blind for which a configuration message has previously been received. Emitted messages from this node have the same properties as those emitted from the Blind Controller node.

This node does not report status within the Node-RED flow editor.

Sample Flow

The figure below represents a sample flow of Blind Controller node can be used to control 6 Qmotion blinds at the one geo location. The flow is initiated by an Injector node configured to run periodically.

Blind Controller Screenshot

The figure below represents a sample flow using the Multi Blind Controller node for the same use case, where the blind configuration is stored in a Cloudant database.

Multi Blind Controller Screenshot

About

node-RED node that determines blind position based on the position of the sun and climatic conditions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 56.9%
  • HTML 43.1%