• Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Widget - Sensor custom buttons

    Dashboard
    dashboard widgets custom buttons
    4
    21
    7377
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jkandasa
      jkandasa @skywatch last edited by

      @skywatch You have to release and click again and again. Also, handle the logic in your Arduino sketch.

      1 Reply Last reply Reply Quote 0
      • skywatch
        skywatch last edited by skywatch

        @jkandasa I have thought about that, but it is sooo tedious without a servant to do it for one! - So I will try programming the arduino node to automatically repeat the signal on seeing the command for the first time, then, when volume is as you like it I can send second command that will stop the loop counting up or down. I guess the same would apply to lighting controls that require a button to be held down to dim or brighten lights via IR?

        jkandasa 1 Reply Last reply Reply Quote 0
        • jkandasa
          jkandasa @skywatch last edited by

          @skywatch

          I guess the same would apply to lighting controls that require a button to be held down to dim or brighten lights via IR?

          This one may not be performed from the MyController side. Again this should be handled by Arduino sketch. I do not get any idea to implement this one with MyController

          1 Reply Last reply Reply Quote 0
          • skywatch
            skywatch last edited by

            @jkandasa

            I do not get any idea to implement this one with MyController

            I have an idea - what about a option to select whether or not to 'repeat' the command on button push (tick box) and then with a variable to define how often the 'message' should be sent per second.

            This needs to be achieved with a way to detect a button push and button release.

            But not something to take your time away from more important things 😉

            jkandasa 1 Reply Last reply Reply Quote 1
            • jkandasa
              jkandasa @skywatch last edited by

              @skywatch Kindly create a request on GitHub page, I will work on this when I get time.

              Thank you!

              1 Reply Last reply Reply Quote 0
              • skywatch
                skywatch last edited by

                @jkandasa Thanks - But I am the only one with use for this and it is better for your time to be spent on new MyController instead! I can manage with it how it is for a long time 😉

                jkandasa 1 Reply Last reply Reply Quote 1
                • jkandasa
                  jkandasa @skywatch last edited by

                  @skywatch Thank you! 🙂

                  1 Reply Last reply Reply Quote 0
                  • skywatch
                    skywatch last edited by skywatch

                    Just an update to show that you guys are awesome.... Here is an image of the current setup...

                    0_1533399149910_IR_Control_Screen.jpg

                    And in case anyone else is stuck with this type of thing, here is the final fully working code.

                    /*
                       Based on IRsendDemo Copyright 2009 Ken Shirriff
                       http://arcfn.com
                    */
                    #include <IRremote.h>
                    /*
                       Yamaha Amp DSP 592
                       Function Code  Len
                    */
                    #define YPower 0x5EA1F807
                    /*  
                     Optoma HD141X Projector
                       Function Code  Len 
                    */
                    #define Power_ON 0x4CB340BF
                    #define Power_OFF 0x4CB3748B
                    //
                    #define power_ON_macro 0x11111111
                    #define power_OFF_macro 0x22222222
                    #define CHILD_ID_FAN 0
                    #define CHILD_ID_HEATER 1
                    #define CHILD_ID_IR 2
                    #define RELAY_ON 0
                    #define RELAY_OFF 1
                    #define Fan_ON 0
                    #define Fan_OFF 1
                    #define Heater_pin 4
                    #define Fan_pin 5
                    // Enable debug prints
                    #define MY_DEBUG
                    
                    // Enable and select radio type attached
                    #define MY_RADIO_NRF24
                    #define MY_RF24_PA_LEVEL   RF24_PA_LOW
                    #define MY_NODE_ID 61
                    #define MY_RF24_CHANNEL (97)
                    #define MY_PARENT_NODE_ID 0
                    #define MY_PARENT_NODE_IS_STATIC
                    //#define MY_REPEATER_FEATURE
                    //#define MY_SIGNING_ATSHA204
                    //#define MY_SIGNING_REQUEST_SIGNATURES
                    unsigned long last_heartbeat_time = 0;
                    unsigned long HEARTBEAT_TIME = 5 * 60000;
                    unsigned long code = 0x12345678;
                    IRsend irsend;
                    #include <Wire.h>
                    #include <MySensors.h>
                    MyMessage msgFan(CHILD_ID_FAN, V_STATUS);
                    MyMessage msgHeater(CHILD_ID_HEATER, V_STATUS);
                    MyMessage msgCode(CHILD_ID_IR, V_IR_SEND);
                    
                    void presentation()
                    {
                      // Send the sketch version information to the gateway
                      sendSketchInfo("MYS-CinemaControl", "0.2");
                    
                      // Register all sensors to gw (they will be created as child devices)
                      present(CHILD_ID_FAN, S_BINARY, "Cinema Fan");
                      wait(100);
                      present(CHILD_ID_HEATER, S_BINARY, "Cinema Heater");
                      wait(100);
                      present(CHILD_ID_IR, S_IR, "Cinema IR Send");
                    }
                    
                    void setup()
                    {
                      pinMode(Fan_pin, OUTPUT); //pin 5
                      digitalWrite(Fan_pin, HIGH);
                      pinMode(Heater_pin, OUTPUT); //pin4
                      digitalWrite(Heater_pin, HIGH);
                    }
                    
                    void loop() {
                      if ((millis() - last_heartbeat_time) > HEARTBEAT_TIME) {
                        sendHeartbeat();
                        last_heartbeat_time = millis();
                      }
                    } 
                    
                    // process incoming message
                    void receive(const MyMessage &message) {
                        if (message.type == V_IR_SEND){
                        unsigned long code = strtoul(message.getString(),NULL,0);
                      
                      if (code == power_OFF_macro)
                      {    
                        irsend.sendNEC(Power_OFF, 32);
                        delay(1500);
                        irsend.sendNEC(YPower, 32);
                        delay(1500);
                        irsend.sendNEC(Power_OFF, 32);
                      }
                      if (code == Power_OFF)
                      {
                        irsend.sendNEC(Power_OFF, 32);
                        delay(3000);
                        irsend.sendNEC(Power_OFF, 32);
                      }
                      else if (code == power_ON_macro)
                      {
                        irsend.sendNEC(Power_ON, 32);
                        delay(2000);
                        irsend.sendNEC(YPower, 32);
                      }
                      else{
                        irsend.sendNEC(code, 32);
                       }
                      }
                        if (message.type == V_STATUS){
                        digitalWrite(message.sensor+4, message.getBool()?RELAY_ON:RELAY_OFF);
                      } 
                    }
                    

                    I managed to get most of the ir code #define statements off the arduino and instead store them in the button code on the pi, which saves memory on the arduino for future expansion.

                    And here is the JSON code for the buttons, the hex codes will need to be changed to whatever you need...

                    [
                     {
                        "name": "Power ON Macro",
                        "payload": "0x11111111",
                        "btnType": "danger"
                      },
                     {
                        "name": "Power OFF Macro",
                        "payload": "0x22222222",
                        "btnType": "danger"
                      },
                      {
                        "name": "Amp Power",
                        "payload": "0x5EA1F807"
                      },
                      {
                        "name": "Amp Vol +",
                        "payload": "0x5EA158A7"
                      },
                      {
                        "name": "Amp Vol -",
                        "payload": "0x5EA1D827"
                      },
                      {
                        "name": "CD",
                        "payload": "0x5EA1A857"
                      },
                      {
                        "name": "Phono",
                        "payload": "0x5EA128D7"
                      },
                      {
                        "name": "Bluray",
                        "payload": "0x5EA1E817"
                      },
                      {
                        "name": "Amp Kodi",
                        "payload": "0x5EA12AD5"
                      },
                     {
                        "name": "Tape",
                        "payload": "0x5EA118E7"
                      },
                     {
                        "name": "Tuner",
                        "payload": "0x5EA16897"
                      },
                     {
                        "name": "V-Aux",
                        "payload": "0x5EA1AA55"
                      },
                      {
                        "name": "Time/Level +",
                        "payload": "0x5EA14AB5"
                      },
                      {
                        "name": "Time/Level -",
                        "payload": "0x5EA14AB5"
                      },
                      {
                        "name": "Effect",
                        "payload": "0x5EA16A95"
                      },
                    {
                    "name" : "2Ch/6Ch",
                    "payload": "0x5EA1E11E"
                    },
                    {
                    "name" : "Prog+",
                    "payload": "0x5EA11AE5"
                    },
                    {
                    "name" : "Prog -",
                    "payload": "0x5EA19A65"
                    },
                    {
                    "name" : "Enhanced",
                    "payload": "0x5EA1916E"
                    },
                      {
                        "name": "Data/Centre/Rear/Swfr",
                        "payload": "0x5EA1619E"
                      }
                     
                    ]
                    
                    jkandasa 1 Reply Last reply Reply Quote 1
                    • jkandasa
                      jkandasa @skywatch last edited by

                      @skywatch Awesome!! great sharing. Thank you so much!

                      1 Reply Last reply Reply Quote 0
                      • skywatch
                        skywatch last edited by

                        @jkandasa I've just added the JSON settings for the amp, it was missing in the first post....Opps! 😉

                        Thank you for making it all possible! 🙂

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post

                        0
                        Online

                        647
                        Users

                        506
                        Topics

                        3.3k
                        Posts

                        Copyright © 2015-2022 MyController.org | Contributors | Localization