new devices in Mysensors 1.5

Moderator: leecollings

tbowmo
Posts: 7
Joined: Thursday 11 June 2015 13:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2480
Location: Denmark
Contact:

new devices in Mysensors 1.5

Post by tbowmo »

Could we get support for the new sensor / variable types, that has been added in Mysensors 1.5?

In particular I'm interested in getting V_RGB, V_RGBW, and V_HVAC_SETPOINT_COLD / V_HVAC_SETPOINT_HEAT to work in domoticz

The two first for LED strips for lightning in my Home theater, and the later for floor heating system, that I'm planing to use mysensors for.
Mysensors HW developer / hacker.
Creator of Sensebender Micro temperature / humidity sensor
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

I think the V_RGB and V_RGBW should already work....

i think there is a typo in the 1.5 library, V_HVAC_SETPOINT_COLD does not exists, but V_HVAC_SETPOINT_COOL does

is there a sketch that is using them ?
Quality outlives Quantity!
tbowmo
Posts: 7
Joined: Thursday 11 June 2015 13:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2480
Location: Denmark
Contact:

Re: new devices in Mysensors 1.5

Post by tbowmo »

There isn't a sketch for hvac yet, as I'm just preparing it. It's almost a chicken and egg situation ;)
Mysensors HW developer / hacker.
Creator of Sensebender Micro temperature / humidity sensor
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

Well... if you can create the chicken, i might be able to support the egg ;) plz send me a PM when your chicken is cooked
Quality outlives Quantity!
betonishard
Posts: 6
Joined: Sunday 17 May 2015 16:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: new devices in Mysensors 1.5

Post by betonishard »

Tested it with 1.5.

Device gets recognized. You can add it as well to your switches section (automatically when you add it)... The lightbulb icon appears...

Receive the error message in the log:
Error: MySensors: Light command received for unknown node_id: 0

Receive an error message when i press the on /off switch (lightbulb icon).
Error sending switch command, check device/hardware


Here is my arduino code:

Code: Select all

// Example sketch showing how to control an RGB Led Strip.
// This example will not remember the last rgb color set after power failure.

#include <MySensor.h>
#include <SPI.h>
#include <TimerOne.h>
#include "Adafruit_WS2801.h"
#ifdef __AVR_ATtiny85__
 #include <avr/power.h>
#endif

#define node 14  // 
#define strip2 0  // sensor number needed in the custom devices set up
int dataPin = 4;       // 'yellow' wire
int clockPin = 3;      // 'green' wire
Adafruit_WS2801 strip = Adafruit_WS2801(74, dataPin, clockPin);
long RGB_values[3] = {0,0,0};
const float mt = 0.247;
MySensor gw; 

void setup()
{
   Serial.begin(115200); // Not sure why this was included
    // Initialize library and add callback for incoming messages
    gw.begin(incomingMessage, node, true);
    
    // Send the sketch version information to the gateway and Controller
    gw.sendSketchInfo("RGB Node", "1.0");
    
    // Register the sensor to gw
    gw.present(strip2, S_RGB_LIGHT);
    
// start with 50% CPU usage. up this if the strand flickers or is slow
  
  // Start up the LED counter
  strip.begin();

  // Update the strip, to start they are all 'off'
  strip.show();
    }



void loop()
{
    // Alway process incoming messages whenever possible
    gw.process();
}

void incomingMessage(const MyMessage &message) {
    // We only expect one type of message from controller. But we better check anyway.
    if (message.type==V_RGB) {
  // starting to process the hex code
        String hexstring = message.getString(); //here goes the hex color code coming from through MySensors (like FF9A00)
        long number = (long) strtol( &hexstring[0], NULL, 16);
        RGB_values[0] = number >> 16;
        RGB_values[1] = number >> 8 & 0xFF;
        RGB_values[2] = number & 0xFF;

        
        colorWipe(Color(RGB_values[0],RGB_values[1],RGB_values[2]), 30);

        
          }
    }
  
void colorWipe(uint32_t c, uint8_t wait) {
  int i;
  
  for (i=0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

    /* Helper functions */

// Create a 15 bit color value from R,G,B
uint32_t Color(byte r, byte g, byte b)
{
  uint32_t c;
  c = r;
  c <<= 8;
  c |= g;
  c <<= 8;
  c |= b;
  return c;
}
    

User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

I'm trying to migrate to the 1.5 libraries, but am having an issue compiling (will reinstall)

But, how do you turn on/off this strip ? maybe you also need S_LIGHT ?

Hope to post some positive news here soon, the RGB(W) should create another type of switch in domoticz (like a zwave color device/applamp)
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

Getting closer:

Code: Select all

send: 2-2-0-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=ok:1.5
send: 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
read: 0-0-2 s=255,c=3,t=6,pt=0,l=1,sg=0:M
sensor started, id=2, parent=0, distance=1
send: 2-2-0-0 s=255,c=3,t=11,pt=0,l=13,sg=0,st=ok:RGB Test Node
send: 2-2-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
send: 2-2-0-0 s=0,c=0,t=26,pt=0,l=0,sg=0,st=ok:
Sketch started...
read: 0-0-2 s=0,c=1,t=40,pt=0,l=6,sg=0:7200FF
RGB command: 7200FF
read: 0-0-2 s=0,c=1,t=3,pt=0,l=3,sg=0:100
Dim command: 100
read: 0-0-2 s=0,c=1,t=40,pt=0,l=6,sg=0:7200FF
RGB command: 7200FF
read: 0-0-2 s=0,c=1,t=3,pt=0,l=2,sg=0:53
Dim command: 53
read: 0-0-2 s=0,c=1,t=2,pt=0,l=1,sg=0:0
Light command: 0
read: 0-0-2 s=0,c=1,t=2,pt=0,l=1,sg=0:0
Light command: 0
read: 0-0-2 s=0,c=1,t=3,pt=0,l=2,sg=0:86
Dim command: 86
The Zipato/Fibaro RGBW/Limitedless/Applamp, have additional commands:
- On
- Off
- Set Level

Is/Will this be supported for S_RGB/S_RGBW too ?

For instance, the sketch can remember the last set RGB/W color
when an V_LIGHT=0 "Off" command is received, it will send #000000 (or cut the power somehow)
when an V_LIGHT=1 "On" command is received, it will use the last set color
when an "V_DIMMER" command is received, it will take the last set color, and dim this (0-100%)

current state in domoticz:
- you will have to add the switch, and press edit to set the color, it will for now always set the level to 100%, for instance, when picking green, it will send #00FF00

This is my test sketch:

Code: Select all

#include <MySensor.h>
#include <SPI.h>

#define CHILD_ID_STRIP 0 // sensor number needed in the custom devices set up
MySensor gw;

void setup()
{
   Serial.begin(115200); // Not sure why this was included
    // Initialize library and add callback for incoming messages
    gw.begin(incomingMessage);
   
    // Send the sketch version information to the gateway and Controller
    gw.sendSketchInfo("RGB Test Node", "1.0");
   
    // Register the sensor to gw
    gw.present(CHILD_ID_STRIP, S_RGB_LIGHT);

    Serial.println("Sketch started...");
}

void loop()
{
    // Alway process incoming messages whenever possible
    gw.process();
}

void incomingMessage(const MyMessage &message) {
    // We only expect one type of message from controller. But we better check anyway.
    if (message.type==V_RGB) {
        // starting to process the hex code
        String hexstring = message.getString(); //here goes the hex color code coming from through MySensors (like FF9A00)
        Serial.print("RGB command: ");
        Serial.println(hexstring);
    }
    else if (message.type==V_DIMMER) {
        String dimlevel = message.getString(); //0-100%
        Serial.print("Dim command: ");
        Serial.println(dimlevel);
    }
    else if (message.type==V_LIGHT) {
        String lstatus = message.getString(); //1=On, 0=Off
        Serial.print("Light command: ");
        Serial.println(lstatus);
    }
}

Changes are in beta version #2689
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

vil1driver wrote:Hi,

Thanks for your hard work..
Could we continue using v_light and v_dimmer ?
V_STATUS 2 Binary status. 0=off 1=on
V_LIGHT 2 Deprecated. Alias for V_STATUS.
V_PERCENTAGE 3 Percentage value. 0-100 (%)
V_DIMMER 3 Deprecated. Alias for V_PERCENTAGE. Dimmer value. 0-100 (%)
Ps: serial.begin is included in mysensors, it's useless to put this in sketch
how do you mean deprecated ? V_LIGHT/V_DIMMER are basic sets?
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

I know what it means, but where did you read that V_LIGHT/V_DIMMER are deprecated?
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

Okey, so its just a rename

I changed it in the domoticz code

but to your original question, is it working now ?
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

Okey, you have to upgrade to the latest beta

I also had compile errors, and I figured out I now have to use the latest Arduino IDE

I uninstalled the previous IDE, and removed the folder
then I installed the latest IDE
then I downloaded the 1.5 library, and copied this to the libraries folder of the ardiono ide, and skipped all existing files

then I could build everything again

Plz let me know if all is working well now
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

sweat, did you implement the on/off, level and write/read the last state in the eprom ?
Maybe you could propose an update to the original mysensors sketch
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

its because I miss-use the light type AC, which has 16 level (0-15)
would have been better if I miss-used the zwave dimmer type that supports 0-100
but as most kaku devices has 16 levels, would this not be OK?
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

Correct, see some posts up regarding the level
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

it does, just tested with the below sketch (you will get a node 254 (FE), make sure accept new hardware is enabled in the settings

Code: Select all

/*
* FakeMySensors
*
* This skecth is intended to crate fake sensors which register and respond to the controller
* 
* Barduino, GizMoCuz 2015
*/

#include <MySensor.h>  
#include <SPI.h>

// SPI Pins
#define CE_PIN 9
#define CS_PIN 10

// Wait times
#define LONG_WAIT 500
#define SHORT_WAIT 50

#define SKETCH_NAME "Test Light"
#define SKETCH_VERSION "v0.3"

//#define ID_S_LIGHT                    4

// Global Vars
unsigned long SLEEP_TIME = 12000; // Sleep time between reads (in milliseconds)
boolean metric = true;
long randNumber;

// Instanciate MySersors Gateway
MySensor gw;

//Instanciate Messages objects

  MyMessage msg_S_LIGHT(1,V_LIGHT);

void setup()  
{ 
  // Random SEED
  randomSeed(analogRead(0));
  
  // Start the gateway
  gw.begin(incomingMessage,254);
  gw.wait(LONG_WAIT);
  Serial.println("GW Started");
  
  // Send the Sketch Version Information to the Gateway
  Serial.print("Send Sketch Info: ");
  gw.sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
  Serial.print(SKETCH_NAME);
  Serial.println(SKETCH_VERSION);
  gw.wait(LONG_WAIT);
  
  // Get controller configuration
  Serial.print("Get Config: ");
  metric = gw.getConfig().isMetric;
  Serial.println(metric ? "Metric":"Imperial");
  gw.wait(LONG_WAIT);
  
  // Register all sensors to gw (they will be created as child devices)
  Serial.println("Presenting Nodes");
  Serial.println("________________");
  
    Serial.println("  S_LIGHT");
    gw.present(1,S_LIGHT);
    gw.wait(SHORT_WAIT);
Serial.println("________________");

}

void loop()      
{ 
  Serial.println("");
  Serial.println("");
  Serial.println("");
  Serial.println("#########################"); 
  randNumber=random(0,101);
  
  Serial.print("RandomNumber:");
  Serial.println(randNumber);
  // Send fake battery level
  Serial.println("Send Battery Level");
  gw.sendBatteryLevel(randNumber);
  gw.wait(LONG_WAIT);
  
    light();
  
  gw.sendBatteryLevel(randNumber);
  gw.wait(SHORT_WAIT);
  gw.process();
  Serial.println("#########################");
  gw.wait(SLEEP_TIME); //sleep a bit
}

void light(){

  bool isLightOn = gw.loadState(1);
  
  Serial.print("Light is: " );
  
  if (isLightOn) {
    Serial.println("On");
    gw.send(msg_S_LIGHT.set(1));
  } else {
    Serial.println("Off");
    gw.send(msg_S_LIGHT.set(0));
  }
  
}

void incomingMessage(const MyMessage &message) {
  switch (message.type) {
    case V_LIGHT:
          gw.saveState(1, message.getBool());
          Serial.print("Incoming change for ID_S_LIGHT:");
          Serial.print(message.sensor);
          Serial.print(", New status: ");
          Serial.println(message.getBool());
    break;
    default: 
      Serial.print("Unknown/UnImplemented message type:");
      Serial.println(message.type);
  }
}
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

the present should already create a device, you do not have to force a send
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

Thanks for reporting, will be fixed in the next update (very soon)
Quality outlives Quantity!
User avatar
gizmocuz
Posts: 2486
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: new devices in Mysensors 1.5

Post by gizmocuz »

Please try beta #2760
Quality outlives Quantity!
LastSamurai
Posts: 15
Joined: Wednesday 26 August 2015 1:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: new devices in Mysensors 1.5

Post by LastSamurai »

Hi,

I tried to use a RGBW mysensor with domoticz. It correclty shows up and I can send off/on commands. What I can't do at the moment is change the color. No event seems to reach the sensor (or in this case actor) node when change the color and I can't pick an RGBW value in the web frontend (only RGB). I am using the newest update from the beta channel (2.2826). Any ideas?
LastSamurai
Posts: 15
Joined: Wednesday 26 August 2015 1:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: new devices in Mysensors 1.5

Post by LastSamurai »

Has anyone already used this?
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest