From c0e7e8531921fc772f6ee1a971573d2908298161 Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Sun, 29 Jan 2017 12:59:52 +0100 Subject: [PATCH] Add info on mysensors S_RGBW_LIGHT (#1899) --- source/_components/light.mysensors.markdown | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/_components/light.mysensors.markdown b/source/_components/light.mysensors.markdown index e5bafe3c251..8abeb4a3cfd 100644 --- a/source/_components/light.mysensors.markdown +++ b/source/_components/light.mysensors.markdown @@ -29,8 +29,11 @@ S_TYPE | V_TYPE ------------|------------- S_DIMMER | [V_DIMMER\* or V_PERCENTAGE\*], [V_LIGHT\* or V_STATUS\*] S_RGB_LIGHT | V_RGB*, [V_LIGHT\* or V_STATUS\*], [V_DIMMER or V_PERCENTAGE] +S_RGBW_LIGHT | V_RGBW*, [V_LIGHT\* or V_STATUS\*], [V_DIMMER or V_PERCENTAGE] -V_TYPES with a star (\*) denote V_TYPES that should be sent at sketch startup. For an S_DIMMER, send both a V_DIMMER/V_PERCENTAGE and a V_LIGHT/V_STATUS message. For an S_RGB_LIGHT, send both a V_RGB and a V_LIGHT/V_STATUS message with a V_DIMMER/V_PERCENTAGE message being optional. Sketch should acknowledge a command sent from controller with the same type. If command invokes a change to off state (including a V_PERCENTAGE or V_RGB message of zero), only a V_STATUS of zero message should be sent. See sketches below for examples. +V_TYPES with a star (\*) denote V_TYPES that should be sent at sketch startup. For an S_DIMMER, send both a V_DIMMER/V_PERCENTAGE and a V_LIGHT/V_STATUS message. For an S_RGB_LIGHT, send both a V_RGB and a V_LIGHT/V_STATUS message with a V_DIMMER/V_PERCENTAGE message being optional. Same principal applies for S_RGBW_LIGHT and V_RGBW. + +Sketch should acknowledge a command sent from controller with the same type. If command invokes a change to off state (including a V_PERCENTAGE, V_RGB, or V_RGBW message of zero), only a V_STATUS of zero message should be sent. See sketches below for examples. For more information, visit the [serial api] of MySensors. @@ -111,10 +114,10 @@ void incomingMessage(const MyMessage &message) { ### {% linkable_title MySensors 2.x example sketch %} ```cpp -/* +/* * Example Dimmable Light * Code adapted from http://github.com/mysensors/MySensors/tree/master/examples/DimmableLight - * + * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * @@ -170,7 +173,7 @@ void presentation() void receive(const MyMessage &message) { - //When receiving a V_STATUS command, switch the light between OFF + //When receiving a V_STATUS command, switch the light between OFF //and the last received dimmer value if ( message.type == V_STATUS ) { Serial.println( "V_STATUS command received..." ); @@ -189,7 +192,7 @@ void receive(const MyMessage &message) //Update constroller status send_status_message(); - + } else if ( message.type == V_PERCENTAGE ) { Serial.println( "V_PERCENTAGE command received..." ); int dim_value = constrain( message.getInt(), 0, 100 ); @@ -202,11 +205,11 @@ void receive(const MyMessage &message) } else { last_state = LIGHT_ON; last_dim = dim_value; - + //Update constroller with dimmer value send_dimmer_message(); } - + } else { Serial.println( "Invalid command received..." ); return;