Nodes with S_CUSTOM Values not appearing



  • I have a node with S_CUSTOM V_VAR1, V_VAR2 which is not appearing in Domoticz.
    Domoticz Version is 3.4944
    I am compiling Serial Gateway on Development train
    Sensor Node is on Development train (my sketch needs a lot of RAM).
    Nodes and Children show up but not the values.



  • More reading on the Forums seems to point to a need to edit MySensorsBase.cpp
    Not looking forward to that!
    But if there is documentation how to customize MySensorsBase.cpp file I will have a go!

    Here are the relevant parts of my custom Sketch:
    It is an Import/Export Utility meter.

    #define MY_NODE_ID 6
    #define CHILD_ID_KWH 0
    #define CHILD_ID_WATT 0
    #define CHILD_ID_VA 0
    #define CHILD_ID_VOLTAGE 0
    #define CHILD_ID_CURRENT 0
    #define CHILD_ID_FREQ 1
    #define CHILD_ID_MAXWATT 1
    #define CHILD_ID_PF 1
    #define CHILD_ID_KWH_EXPORT 1
    
    
    
     present(CHILD_ID_KWH, S_CUSTOM);
     present(CHILD_ID_WATT, S_CUSTOM);
     present(CHILD_ID_MAXWATT, S_CUSTOM); 
     present(CHILD_ID_VA, S_CUSTOM);
     present(CHILD_ID_VOLTAGE, S_CUSTOM);
     present(CHILD_ID_CURRENT, S_CUSTOM);
     present(CHILD_ID_FREQ, S_CUSTOM); 
     present(CHILD_ID_PF, S_CUSTOM); 
     present(CHILD_ID_KWH_EXPORT, S_CUSTOM);     
    
    MyMessage energyMsg(CHILD_ID_KWH, V_VAR1);
    MyMessage powerMsg(CHILD_ID_WATT, V_VAR2);
    MyMessage vaMsg(CHILD_ID_VA, V_VAR3);
    MyMessage voltageMsg(CHILD_ID_VOLTAGE, V_VAR4);
    MyMessage currentMsg(CHILD_ID_CURRENT, V_VAR5);
    MyMessage freqMsg(CHILD_ID_FREQ, V_VAR1);
    MyMessage powermaxMsg(CHILD_ID_MAXWATT, V_VAR2);
    MyMessage pfMsg(CHILD_ID_PF, V_VAR3);
    MyMessage energyexportMsg(CHILD_ID_KWH_EXPORT, V_VAR4);
    

    Log:

    2016-03-12 21:09:02.115 Domoticz V3.4944 (c)2012-2016 GizMoCuz
    2016-03-12 21:09:02.116 Build Hash: 92e8ef0, Date: 2016-03-11 20:54:56
    2016-03-12 21:09:02.117 Startup Path: /root/domoticz/
    2016-03-12 21:09:02.158 Active notification subsystems: http (1/11)
    2016-03-12 21:09:02.163 WebServer(HTTP) started on address: 0.0.0.0 with port 8080
    2016-03-12 21:09:02.184 WebServer(SSL) started on address: 0.0.0.0 with port 443
    2016-03-12 21:09:02.187 Proxymanager started.
    2016-03-12 21:09:02.190 Starting shared server on: 0.0.0.0:6144
    2016-03-12 21:09:02.193 RxQueue: queue worker started...
    2016-03-12 21:09:02.194 TCPServer: shared server started...
    2016-03-12 21:09:04.196 EventSystem: reset all events...
    2016-03-12 21:09:04.197 EventSystem: reset all device statuses...
    2016-03-12 21:09:04.199 EventSystem: Started
    2016-03-12 21:09:05.199 MySensors: Using serial port: /dev/ttyUSB1
    2016-03-12 21:09:06.685 MySensors: Gateway Ready...
    2016-03-12 21:09:06.761 MySensors: Gateway Version: 2.0.0-beta
    2016-03-12 21:09:23.957 Incoming connection from: 192.168.20.115

    You can see the Node and Children registering in the Domoticz:

    2 MySensors Serial Gateway Yes MySensors Gateway USB
    Version: 2.0.0-beta Setup /dev/ttyUSB1 5 Minutes

    Nodes
    5 Electricity Meter Unknown 1.0 2 2016-03-12 21:11:10
    Children
    0 S_CUSTOM true 2016-03-12 21:11:50
    1 S_CUSTOM true 2016-03-12 21:11:10
    Showing 1 to 2 of 2 entries
    FirstPrevious1NextLast


  • Hero Member

    Domoticz doesn't handle the S_CUSTOM type. The V_VAR datatypes (related to other S_ types) can not be made visible. So functionality is rather limited.



  • OK, yes you are right looks like S_CUSTOM values are not supported.
    So for those of you who are brave enough to make your own Custom MySensors nodes read on...

    I wish there was an easy way to add your own custom sensor, as I need to make many of them.
    pH Electrical Conductivity(EC), Tank Water Volume (Liters), UVa and UVb in mW/cm2 ioniziing radiation in uSv to name a few of my sensor devices.
    But right now I need to get my kWh import/export transmitter recognized by Domoticz.
    So I guess I will just have to find a work around as Domoticz looks quite good stacked up against other free controllers.
    Here is what I have done so far...

    I have discovered you can hack the hardware/MySensorsBase.cpp file. This is a really crude hack but I admit I am no C expert. Maybe someone can point out a better way of doing this.

    I am running Debian Lime on and Olimex A10.
    You will need the Source files, so if running on a RasberryPi you cannot use the compiled binaries, you will need to download the source code from github.
    Compile your domoticz and get it running first. If you do not want to run Domoticz as root then make sure you don't compile as root as you'll have to start all over again, downloading from github. A trap I fell into.
    Also you need to uninstall the boost libraries and get the latest one. Doing the sudo apt-get update and then sudo apt-get upgrade doesn't seem to get the correct boost libraries.
    Google how to remove current boost and how to install latest ver.

    On with the task... Here are the values I am sending in my sketch:

    imported energy (CHILD_ID_0, V_VAR1);
    real power (CHILD_ID_0, V_VAR2);
    apparent power (CHILD_ID_0, V_VAR3);
    voltage (CHILD_ID_0, V_VAR4);
    current (CHILD_ID_0, V_VAR5);

    freq (CHILD_ID_1, V_VAR1);
    peak power CHILD_ID_1, V_VAR2);
    pf (CHILD_ID_1, V_VAR3);
    exported energy (CHILD_ID_1, V_VAR4);

    By trial and error I found there are 4 places you need to edit inside MySensorsBase.cpp
    Find the line starting case S_CUSTOM:
    and modify as below

    	case S_CUSTOM:
    		vType = V_VAR5;
    		bDoAdd = true;
    		break;
    

    Find line starting : case V_CURRENT:
    Then add the V_VAR1 through V_VAR5 variables that you are using

    case V_CURRENT:
    	if (pChild->GetValue(vType, floatValue))
    		SendCurrentSensor(cNode, pChild->batValue, floatValue, 0, 0, (!pChild->childName.empty()) ? pChild->childName : "Current");
    	break;
    
    
    case V_VAR1:
    	if (pChild->GetValue(vType, floatValue))
    	{
    			if (pChild->childID == 0)
    			SendKwhMeter(pChild->nodeID, 10, pChild->batValue, 0, floatValue, (!pChild->childName.empty()) ? pChild->childName : "Imported Energy");
    
    	else
    			SendCustomSensor(11, 11, pChild->batValue, floatValue, ("Hz") ? pChild->childName : "Line Frequency", "Hz");
    
    	}
    	break;
    case V_VAR2:
    	if (pChild->GetValue(vType, floatValue))
    	{
    			if (pChild->childID == 0)
    			SendWattMeter(cNode, 20, pChild->batValue, floatValue,  (!pChild->childName.empty()) ? pChild->childName : "Real Power");
    	else
    			SendWattMeter(cNode, 21, pChild->batValue, floatValue,  (!pChild->childName.empty()) ? pChild->childName : "Peak VA");
    	}
    	break;
    case V_VAR3:
    	if (pChild->GetValue(vType, floatValue))
    	{
    			if (pChild->childID == 0)
    			SendWattMeter(cNode, 30, pChild->batValue, floatValue,  (!pChild->childName.empty()) ? pChild->childName : "Apparent Power");
    	else
    			SendCustomSensor(31, 31, pChild->batValue, floatValue, ("pf") ? pChild->childName : "Power Factor", " ");
    	}
    	break;
    case V_VAR4:
    	if (pChild->GetValue(vType, floatValue))
    	{
    			if (pChild->childID == 0)
    			SendVoltageSensor(cNode, 40, pChild->batValue, floatValue,  (!pChild->childName.empty()) ? pChild->childName : "Supply Voltage");
    	else
    			SendKwhMeter(pChild->nodeID, 41, pChild->batValue, 0, floatValue, (!pChild->childName.empty()) ? pChild->childName : "Exported Energy");
    
    	}
    	break;
    case V_VAR5:
    	if (pChild->GetValue(vType, floatValue))
    		SendCurrentSensor(cNode, pChild->batValue, floatValue, 0, 0, (!pChild->childName.empty()) ? pChild->childName : "Current");
    	break;
    

    Next find the section: starting: case V_VAR1: //Custom value
    Change as below:

    	case V_VAR1: //Custom value
    	case V_VAR2:
    	case V_VAR3:
    	case V_VAR4:
    	case V_VAR5:
    		pChild->SetValue(vType, (float)atof(payload.c_str()));
    		bHaveValue = true;
    		break;
    

    Find this section: case V_VAR1:
    And change as below

    	case V_VAR1:
    	case V_VAR2:
    	case V_VAR3:
    	case V_VAR4:
    	case V_VAR5:
    		//send back a previous stored custom variable
    		tmpstr = "";
    		GetVar(node_id, child_sensor_id, sub_type, tmpstr);
    		SendNodeCommand(node_id, child_sensor_id, message_type, sub_type, tmpstr);
    		break;
    

    After making changes to the file you must run "make" again to compile domoticz binary.
    It is a lot faster to "make" subsequent times.

    cmake -DCMAKE_BUILD_TYPE=Release -modified .
    make


  • I had a problem with S_DUST to Domoticz. Gizmocuz implemented a function just after two days(wow) and now when I send S_DUST, V_LEVEL it appear as Custom, try to send S_DUST and maybe this can help you?



  • @flopp
    Thanks for that, yes I noticed your thread somewhere and I was delighted to see gizmocuz working on your issue. Unfortunately the changes made broke my workaround hack. It just means I need to look for a more conventional solution that does not include modifying cpp files.
    What I will do is re-code my mysensor nodes to use other variables such as V_WATTS etc rather than V_VAR1, VAR2 etc.


Log in to reply
 

Suggested Topics

  • 5
  • 5
  • 2
  • 1
  • 4
  • 3

60
Online

11.4k
Users

11.1k
Topics

112.7k
Posts