Page 2 of 3
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Sunday 11 October 2015 16:20
by gizmocuz
yugoos wrote:gizmocuz wrote:This is stated in the code (in the remarks)
You need the latest domoticz beta as there have been many changes to the mysensors implementation lately
I missed that line, sorry.
I am running a beta release for mysensors stuff so i can use rgb switches...i am however a bit hesitant to upgrade to latest beta because of some problems with counter values and a corrupt database..
Thanx,
Yuri
you should fix/check your database.
There are no problems with counters, unless you implemented something 'wrong/different' in your sketches.
Stable = beta published as stable, so if you encounter any issues, its best to find them now before we release a new stable
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Sunday 11 October 2015 16:41
by yugoos
Nothing was changed in my sketches and things were running fine for weeks, but after updating beta (cant remember the version, i think it was the first version with power/energy choise) powerpulsecounter values were devided by thousand and written in the database that way, this was the only change!
I posted my counter problem in
http://www.domoticz.com/forum/viewtopic.php?f=6&t=8163
My database is fixed by export/import, temperature and meter tables were corrupt and had to be recreated...not sure what caused corruption...
P.s. We're getting a bit offtopic ...
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Sunday 11 October 2015 17:22
by gizmocuz
This is outside the OP topic...
Anyway, good it runned for weeks, but it could have been weeks wrong.
See the good discussion about the correct implementation of kwh counters in mysensors.
It means you have to update your sketch, as this is not going to change
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Friday 16 October 2015 18:09
by TheoL
yugoos wrote:gizmocuz wrote:This is stated in the code (in the remarks)
You need the latest domoticz beta as there have been many changes to the mysensors implementation lately
I missed that line, sorry.
I am running a beta release for mysensors stuff so i can use rgb switches...i am however a bit hesitant to upgrade to latest beta because of some problems with counter values and a corrupt database..
Thanx,
Yuri
I tried the example of Gizmocuz as well. And indeed you'll need the latest Beta as it gives me the same result on my production, as your sketch
I'm waiting for some parts, so that I can make my MySensors ethernet gateway. I want to use that to share it between my production Domoticz and a separat Beta Domoticz version on another Pi.
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Saturday 14 November 2015 11:11
by adamnmcc
Hi,
i just implemented this in my living room and have the colour picker and slider working.
What i wondered is if the sketch could be expanded to accept effects like Hyperion? With Christmas coming up i'd like to setup some nice blinking colours or a fire effect.
is this within the realms of possibility?
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Saturday 21 November 2015 15:00
by gizmocuz
adamnmcc wrote:Hi,
i just implemented this in my living room and have the colour picker and slider working.
What i wondered is if the sketch could be expanded to accept effects like Hyperion? With Christmas coming up i'd like to setup some nice blinking colours or a fire effect.
is this within the realms of possibility?
You can make your own sketch for this (maybe share it *g*), that has 1 normal on/off light switch
then internally you do your magic with the colors if the light switch is on
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Sunday 22 November 2015 9:50
by richardtrip
adamnmcc wrote:Hi,
i just implemented this in my living room and have the colour picker and slider working.
What i wondered is if the sketch could be expanded to accept effects like Hyperion? With Christmas coming up i'd like to setup some nice blinking colours or a fire effect.
is this within the realms of possibility?
Check this project:
http://forum.mysensors.org/topic/2169/w ... od-light/8
You can enhance it with extra effects and control it with domoticz
Verstuurd vanaf mijn SM-G925F met Tapatalk
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Monday 23 November 2015 8:58
by adamnmcc
Awesome,
thanks for that, i'm sure i can make something out of this. i've got two strips of 51 leds so might take a bit of fiddling.
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Thursday 11 February 2016 13:29
by deennoo
Really great !
Can be cool if the sketch allow a smooth fadding from a color to another to make it less "computer change"
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Sunday 13 March 2016 12:31
by franzelare
I'm currently testing a mysensor node with RGB led attached to it, works fine so for.
through the color picker of domoticz I can change the setting, but I like to update the color based on other inputs on my server
or drive the color through scenes I select for my Hue lighting
any way to send the RGB code through lua script or json?
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Friday 20 May 2016 20:04
by macieiks
Hello,
Is there any way to convert "old version" of the code from 1st page, to the newest MySensors 2.0 API?
Code: Select all
[spoiler]/*
PROJECT: MySensors / RGB test for Light & Sensor
PROGRAMMER: AWI/GizMoCuz
DATE: september 27, 2015/ last update: October 10, 2015
FILE: AWI_RGB.ino
LICENSE: Public domain
Hardware: Nano and MySensors 1.5
Special:
uses Fastled library with NeoPixel (great & fast RBG/HSV universal library) https://github.com/FastLED/FastLED
Remarks:
Fixed node-id
Added option to request/apply last light state from gateway
Domoticz typicals - 2015 10 10:
- Domoticz is using HUE values internally, there might be a slight difference then using direct RGB colors.
*/
#include <MySensor.h>
#include <SPI.h>
#include <FastLED.h>
const int stripPin = 4 ; // pin where 2812 LED strip is connected
const int numPixel = 3 ; // set to number of pixels
#define NODE_ID 254 // fixed MySensors node id
#define CHILD_ID 0 // Child Id's
CRGB leds[numPixel];
char actRGBvalue[] = "000000"; // Current RGB value
uint16_t actRGBbrightness = 0xFF ; // Controller Brightness
int actRGBonoff=0; // OnOff flag
MySensor gw;
MyMessage lastColorStatusMsg(CHILD_ID,V_VAR1);
void setup() {
FastLED.addLeds<NEOPIXEL, stripPin >(leds, numPixel); // initialize led strip
gw.begin(incomingMessage, NODE_ID, false); // initialize MySensors
gw.sendSketchInfo("AWI RGB Light", "1.1");
gw.present(CHILD_ID, S_RGB_LIGHT); // present to controller
// Flash the "hello" color sequence: R, G, B, black.
colorBars();
//Request the last stored colors settings
gw.request(CHILD_ID, V_VAR1);
}
void loop() {
gw.process(); // wait for incoming messages
}
void colorBars()
{
SendColor2AllLEDs( CRGB::Red ); FastLED.show(); delay(500);
SendColor2AllLEDs( CRGB::Green ); FastLED.show(); delay(500);
SendColor2AllLEDs( CRGB::Blue ); FastLED.show(); delay(500);
SendColor2AllLEDs( CRGB::Black ); FastLED.show(); delay(500);
}
void SendColor2AllLEDs(const CRGB lcolor)
{
for(int i = 0 ; i < numPixel ; i++) {
leds[i] = lcolor;
}
}
void SendLastColorStatus()
{
String cStatus=actRGBvalue+String("&")+String(actRGBbrightness)+String("&")+String(actRGBonoff);
gw.send(lastColorStatusMsg.set(cStatus.c_str()));
}
String getValue(String data, char separator, int index)
{
int found = 0;
int strIndex[] = {0, -1};
int maxIndex = data.length()-1;
for(int i=0; i<=maxIndex && found<=index; i++){
if(data.charAt(i)==separator || i==maxIndex){
found++;
strIndex[0] = strIndex[1]+1;
strIndex[1] = (i == maxIndex) ? i+1 : i;
}
}
return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
}
void incomingMessage(const MyMessage &message) {
if (message.type == V_RGB) { // check for RGB type
actRGBonoff=1;
strcpy(actRGBvalue, message.getString()); // get the payload
SendColor2AllLEDs(strtol(actRGBvalue, NULL, 16));
SendLastColorStatus();
}
else if (message.type == V_DIMMER) { // if DIMMER type, adjust brightness
actRGBonoff=1;
actRGBbrightness = map(message.getLong(), 0, 100, 0, 255);
FastLED.setBrightness( actRGBbrightness );
SendLastColorStatus();
}
else if (message.type == V_STATUS) { // if on/off type, toggle brightness
actRGBonoff = message.getInt();
FastLED.setBrightness((actRGBonoff == 1)?actRGBbrightness:0);
SendLastColorStatus();
}
else if (message.type==V_VAR1) { // color status
String szMessage=message.getString();
strcpy(actRGBvalue, getValue(szMessage,'&',0).c_str());
actRGBbrightness=atoi(getValue(szMessage,'&',1).c_str());
actRGBonoff=atoi(getValue(szMessage,'&',2).c_str());
SendColor2AllLEDs(strtol(actRGBvalue, NULL, 16));
FastLED.setBrightness((actRGBonoff == 1)?actRGBbrightness:0);
}
FastLED.show();
}
[/spoiler]
Maciek
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Monday 11 July 2016 10:22
by toreandre
macieiks wrote:Hello,
Is there any way to convert "old version" of the code from 1st page, to the newest MySensors 2.0 API?
Maciek
Take a look at this document.
https://docs.google.com/document/d/1NKq ... qf1v763257
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Wednesday 10 August 2016 18:55
by Ritmeester
I have just installed on a test system MySensors with USB connection. (Arduino Nano V3.0)
Is it possible to send from Domoticz LED effects (patterns) to this LED WS2812B LED strip with MySensors
Example:
When the doorbell rings I want a white (walking) effect on this LED strip.
When a door is open I want the LED strip to be red and white per LED (pixel)
And more.
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Wednesday 10 August 2016 19:06
by gizmocuz
You can program your mysensor node like you this.
For example , have 4 'mode' switches in the sketch, when the doorbell rings, you activate this switch (and thus the effect)
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Thursday 11 August 2016 18:18
by Ritmeester
Hi gizmocuz,
I understand that this is for you easy to make, but not for me and I think more people it is not. Is it possible that you make a basic sketch with two “mode” switches so that I can understand what happen in this sketch?
If I understand the basic sketch, than I can extend the sketch with my own patterns and switches.
It would be really nice if you , or someone else, can make such a sketch with good comments in the sketch.
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Friday 12 August 2016 8:19
by gizmocuz
For an example how to get a switch working, see the 'RelayWithButtonActuator' example
Try extending this to two switches
To get better insight what you can do with MySensors, it is also good to play with the 'MockMySensors' example
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Sunday 14 August 2016 17:16
by Ritmeester
Is there someone who has converted the sketch from gizmocus to MySensors 2.0?
viewtopic.php?t=8039#p57521
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Tuesday 16 August 2016 13:55
by Ritmeester
I’m trying to get the sketch from gizmocuz to work with MySensors 2.0. I have made the necessary conversion from MySensors 1.5 to 2.0. It compiles without errors.
When I upload this sketch to the Arduino Nano and run it, I see in Domoticz this:

- 2016-08-16_13-49-22.png (171.93 KiB) Viewed 8146 times
I have made a dimmer switch in Domoticz and I see the “colorwheel”

- 2016-08-16_13-50-22.png (263.47 KiB) Viewed 8146 times
If I run the sketch the “SendColor2AllLEDs” works. And then it stops because I don’t get any information from Domoticz to this Node. So, Domoticz is not sending commands, or it is not receiving commands.
Maybe (pretty possible) that I have overlooked something but I don’t know what.
Sketch:
Code: Select all
// PROJECT: MySensors / RGB test for Light & Sensor
// PROGRAMMER: AWI/GizMoCuz
// DATE: september 27, 2015/ last update: October 10, 2015
// LAST UPDATE: August 16, 2016 by Ritmeester
// FILE: AWI_RGB.ino
// LICENSE: Public domain
// Hardware: Nano and MySensors 2.0
// Special:
// uses Fastled library with NeoPixel (great & fast RBG/HSV universal library) https://github.com/FastLED/FastLED
// Remarks:
// Fixed node-id
// Added option to request/apply last light state from gateway
// Domoticz typicals - 2015 10 10:
// - Domoticz is using HUE values internally, there might be a slight difference then using direct RGB colors.
// Enable debug prints to serial monitor
// #define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Enable repeater functionality for this node
#define MY_REPEATER_FEATURE
#include <MySensors.h>
#include <SPI.h>
#include <FastLED.h>
#define LED_PIN 4 // Pin to connect WS2812B (strip)
#define NUM_LEDS 10
#define COLOR_ORDER GRB // It's GRB for WS2812B
#define LED_TYPE WS2812B // What kind of strip are you using (APA102, WS2801 or WS@2812B
#define NODE_ID 254 // fixed MySensors node id
#define CHILD_ID 0 // Child Id's
CRGB leds[NUM_LEDS];
char actRGBvalue[] = "000000"; // Current RGB value
uint16_t actRGBbrightness = 0xFF ; // Controller Brightness
int actRGBonoff = 0; // OnOff flag
MyMessage lastColorStatusMsg(CHILD_ID, V_VAR1);
void presentation() {
sendSketchInfo("AWI RGB Light", "1.1");
present(CHILD_ID, S_RGB_LIGHT); // present to controller
}
void setup() {
LEDS.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2812B - initialize led strip
// Flash the "hello" color sequence: R, G, B, black.
colorBars();
//Request the last stored colors settings
request(CHILD_ID, V_VAR1);
}
void receive(const MyMessage &message) {
}
void loop() {
}
void colorBars()
{
SendColor2AllLEDs( CRGB::Red ); FastLED.show(); delay(500);
SendColor2AllLEDs( CRGB::Green ); FastLED.show(); delay(500);
SendColor2AllLEDs( CRGB::Blue ); FastLED.show(); delay(500);
SendColor2AllLEDs( CRGB::Black ); FastLED.show(); delay(500);
}
void SendColor2AllLEDs(const CRGB lcolor)
{
for (int i = 0 ; i < NUM_LEDS ; i++) {
leds[i] = lcolor;
}
}
void SendLastColorStatus()
{
String cStatus = actRGBvalue + String("&") + String(actRGBbrightness) + String("&") + String(actRGBonoff);
send(lastColorStatusMsg.set(cStatus.c_str()));
}
String getValue(String data, char separator, int index)
{
int found = 0;
int strIndex[] = {0, -1};
int maxIndex = data.length() - 1;
for (int i = 0; i <= maxIndex && found <= index; i++) {
if (data.charAt(i) == separator || i == maxIndex) {
found++;
strIndex[0] = strIndex[1] + 1;
strIndex[1] = (i == maxIndex) ? i + 1 : i;
}
}
return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}
void incomingMessage(const MyMessage &message) {
if (message.type == V_RGB) { // check for RGB type
actRGBonoff = 1;
strcpy(actRGBvalue, message.getString()); // get the payload
SendColor2AllLEDs(strtol(actRGBvalue, NULL, 16));
SendLastColorStatus();
}
else if (message.type == V_DIMMER) { // if DIMMER type, adjust brightness
actRGBonoff = 1;
actRGBbrightness = map(message.getLong(), 0, 100, 0, 255);
FastLED.setBrightness( actRGBbrightness );
SendLastColorStatus();
}
else if (message.type == V_STATUS) { // if on/off type, toggle brightness
actRGBonoff = message.getInt();
FastLED.setBrightness((actRGBonoff == 1) ? actRGBbrightness : 0);
SendLastColorStatus();
}
else if (message.type == V_VAR1) { // color status
String szMessage = message.getString();
strcpy(actRGBvalue, getValue(szMessage, '&', 0).c_str());
actRGBbrightness = atoi(getValue(szMessage, '&', 1).c_str());
actRGBonoff = atoi(getValue(szMessage, '&', 2).c_str());
SendColor2AllLEDs(strtol(actRGBvalue, NULL, 16));
FastLED.setBrightness((actRGBonoff == 1) ? actRGBbrightness : 0);
}
FastLED.show();
}
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Tuesday 16 August 2016 18:28
by Ritmeester
gizmocuz wrote:You can program your mysensor node like you this.
For example , have 4 'mode' switches in the sketch, when the doorbell rings, you activate this switch (and thus the effect)
Ok, this I understand. I have it working with a I/O board (MCP23S17). I have made two switches in Domoticz and every switch presents a “mode”.
Now I want it to be handled by MySensors OTA and with ONE switch.
I really don’t know where to start because I can’t understand HOW signals from a switch goes Over The Air to my node.
- What kind of switch I have to make?
- How do I program the switch to send commands?
I search in this forum at the MySensors forum but I can’t find an answer to get understand this.
Re: MySensors S_RGB_LIGHT WS2812 ledstrip
Posted: Tuesday 16 August 2016 18:33
by gizmocuz
its very easy, maybe you are thinking WAY to diffucult
Make a mysensors sketch
Add 4 V_LIGHT in it
in the receive function, handle the lights, and control your real rgb