Presenting and controlling variables in domoticz



  • Hello,

    having trouble controling multiple actuators in domoticz.
    I have made arduino sketch with preloaded setpoints for outside light controlling, in case domoticz is offline or unreachable after power outage etc.
    I have switch on/off setpoints and time delay for switch off

    When i activate present(RGB_RGBChild, S_RGB_LIGHT, "Ees RGB valik") then also time-delay is automatically adjusted by it.

    MyMessage msgTe1(CHILD_ID_Te1, V_TEMP);
    MyMessage msgSp21(CHILD_ID_Sp21, V_HVAC_SETPOINT_HEAT);         //seadearvu muutmine kaugelt
    MyMessage msgSp22(CHILD_ID_Sp22, V_HVAC_SETPOINT_COOL);
    MyMessage msgvalgus(CHILD_ID_valgus, V_LEVEL);
    MyMessage msgaeg2(CHILD_ID_aeg2, V_PERCENTAGE);
    
    void presentation()  {
      sendSketchInfo("Valgus", "1.0");  // seadme nimi, versioon domoticzile
      present(CHILD_ID_Te1, S_TEMP, "Pooningul");        //anname anduri id, liigi, nime domoticzile
      present(CHILD_ID_valgus, S_LIGHT_LEVEL, "Valgustugevus"); //current level lux
      present(CHILD_ID_Sp21, S_LIGHT_LEVEL, "Valgus sisse"); // light on
      present(CHILD_ID_Sp22, S_LIGHT_LEVEL, "Valgus valja"); // light off
      present(CHILD_ID_aeg2, S_DIMMER, "Valguse viide valja");  // time delay off 
    

    When i added ws2812 RGB switch everything got mixed up, especially time delay feature, but also switching in domoticz activated CHILD_ID_Sp21 and CHILD_ID_Sp22(no values were changed)

    MyMessage msgTe1(CHILD_ID_Te1, V_TEMP);
    MyMessage msgSp21(CHILD_ID_Sp21, V_HVAC_SETPOINT_HEAT);         //seadearvu muutmine kaugelt
    MyMessage msgSp22(CHILD_ID_Sp22, V_HVAC_SETPOINT_COOL);
    MyMessage msgvalgus(CHILD_ID_valgus, V_LEVEL);
    MyMessage msgaeg2(CHILD_ID_aeg2, V_PERCENTAGE);
    
    
    
    MyMessage lightRGBMsg(RGB_LightChild,  V_RGB);        // standard messages, light
      MyMessage lightdimmerMsG(RGB_LightChild ,V_DIMMER); 
    MyMessage lightOnOffMessage(RGB_LightChild, V_STATUS);
    
    void presentation()  {
      sendSketchInfo("Valgus", "1.0");  // seadme nimi, versioon domoticzile
      present(CHILD_ID_Te1, S_TEMP, "Pooningul");        //anname anduri id, liigi, nime domoticzile
      present(CHILD_ID_valgus, S_LIGHT_LEVEL, "Valgustugevus"); //current level lux
      present(CHILD_ID_Sp21, S_LIGHT_LEVEL, "Valgus sisse"); // light on
      present(CHILD_ID_Sp22, S_LIGHT_LEVEL, "Valgus valja"); // light off
      present(CHILD_ID_aeg2, S_DIMMER, "Valguse viide valja");  // time delay off 
    
      present(RGB_RGBChild, S_RGB_LIGHT, "Ees RGB valik");// present to controller
      present(RGB_LightChild, S_LIGHT, "Ees on/off/dim ");
      present(RGB_SolidColorChild, S_LIGHT, "Ees on/off värv" );
      present(RGB_TextColorChild, S_INFO, "Ees värvi tekst" );  
      present(RGB_AlarmPatternChild, S_BINARY, "Ees vilkuv pu/va" );
      present(RGB_NextPatternChild, S_DIMMER, "Ees RGB muster" );
    

    Each child is presented in domoticz correctly with correct name.
    Is there even a way to use multiple same type actuators in a sketch?

    To update preloaded setpoints from arduino to domoticz, i have this added (which might be the problem?)

    void receive(const MyMessage &message) {
    
      if (message.type == V_HVAC_SETPOINT_HEAT) {
        Sp21 = message.getFloat();
      }
      if (message.type == V_HVAC_SETPOINT_COOL) {
        Sp22 = message.getFloat();
      }
    
      if (message.type == V_PERCENTAGE) {
        aeg2 = message.getFloat();
      }
      sendNewStateToGateway();
    

    and

    void sendNewStateToGateway() {
    
      send(msgSp21.set(Sp21));
      send(msgSp22.set(Sp22));
      send(msgaeg2.set(aeg2));
    
    }
    

    Have googled and searched mysensors/domoticz forums but no results. I'm more like hobby programmer if that's the word and self somewhat learned by google for a few years now.



  • Cannot get the point what you exactly mean but I think you should check for what child the message is for:
    if(message.sensor == CHILD_ID_aeg2 && message.type == ...) { ..do suff.. }



  • I cannot use multiple V_PERCENTAGE values. Because if a change a value in domo, both are changing (dime delay(aeg2)) and RGB dimmer..



  • @pjr said in Presenting and controlling variables in domoticz:

    Cannot get the point what you exactly mean but I think you should check for what child the message is for:
    if(message.sensor == CHILD_ID_aeg2** && message.type == ...) { ..do suff.. }

    Thank you, message.sensor was the thing i needed. Browsed cpp and h files in mysensors library and googled, but couldn't find variables to use with message.*.
    😃


Log in to reply
 

Suggested Topics

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

22
Online

11.2k
Users

11.1k
Topics

112.5k
Posts