Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. Domoticz
  4. Error Sending switch command

Error Sending switch command

Scheduled Pinned Locked Moved Domoticz
57 Posts 11 Posters 26.3k Views 5 Watching
  • 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.
  • N Offline
    N Offline
    NBM
    wrote on last edited by
    #38

    The sketch to the relay

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik Ekblad
     * 
     * DESCRIPTION
     * Example sketch for a "light switch" where you can control light or something 
     * else from both HA controller and a local physical button 
     * (connected between digital pin 3 and GND).
     * This node also works as a repeader for other nodes
     * http://www.mysensors.org/build/relay
     */ 
    
    #include <MySensor.h>
    #include <SPI.h>
    #include <Bounce2.h>
    
    #define RELAY_PIN  4  // Arduino Digital I/O pin number for relay 
    #define BUTTON_PIN  3  // Arduino Digital I/O pin number for button 
    #define CHILD_ID 1   // Id of the sensor child
    #define RELAY_ON 0
    #define RELAY_OFF 1
    
    Bounce debouncer = Bounce(); 
    int oldValue=0;
    bool state;
    MySensor gw;
    MyMessage msg(CHILD_ID,V_LIGHT);
    
    void setup()  
    {  
      gw.begin(incomingMessage, AUTO, true);
    
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("RELAY_BUTTON_JUL", "1.0");
    
     // Setup the button
      pinMode(BUTTON_PIN,INPUT);
      // Activate internal pull-up
      digitalWrite(BUTTON_PIN,HIGH);
      
      // After setting up the button, setup debouncer
      debouncer.attach(BUTTON_PIN);
      debouncer.interval(5);
    
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID, S_LIGHT);
    
      // Make sure relays are off when starting up
      digitalWrite(RELAY_PIN, RELAY_OFF);
      // Then set relay pins in output mode
      pinMode(RELAY_PIN, OUTPUT);   
          
      // Set relay to last known state (using eeprom storage) 
      state = gw.loadState(CHILD_ID);
      digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
    }
    
    
    /*
    *  Example on how to asynchronously check for new messages from gw
    */
    void loop() 
    {
      gw.process();
      debouncer.update();
      // Get the update value
      int value = debouncer.read();
      if (value != oldValue && value==0) {
          gw.send(msg.set(state?false:true), true); // Send new state and request ack back
      }
      oldValue = value;
    } 
     
    void incomingMessage(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.isAck()) {
         Serial.println("This is an ack from gateway");
      }
    
      if (message.type == V_LIGHT) {
         // Change relay state
         state = message.getBool();
         digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
         // Store state in eeprom
         gw.saveState(CHILD_ID, state);
        
         // Write some debug info
         Serial.print("Incoming change for sensor:");
         Serial.print(message.sensor);
         Serial.print(", New status: ");
         Serial.println(message.getBool());
       } 
    }
    

    Log from gateway:
    1;255;3;0;11;RELAY_BUTTON_JUL
    0;0;3;0;9;read: 1-1-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
    1;255;3;0;12;1.0
    0;0;3;0;9;read: 1-1-0 s=1,c=0,t=3,pt=0,l=0,sg=0:
    1;1;0;0;3;
    0;0;3;0;9;send: 0-0-1-1 s=1,c=1,t=2,pt=0,l=1,sg=0,st=fail:1
    0;0;3;0;9;read: 4-4-0 s=1,c=1,t=0,pt=7,l=5,sg=0:17.9
    4;1;1;0;0;17.9

    0;0;3;0;9;read: 4-4-0 s=0,c=1,t=1,pt=7,l=5,sg=0:44.4
    4;0;1;0;1;44.4

    Without relay:
    0;0;3;0;9;send: 0-0-1-1 s=1,c=1,t=2,pt=0,l=1,sg=0,st=ok:1
    0;0;3;0;9;read: 1-1-0 s=1,c=1,t=2,pt=0,l=1,sg=0:1
    1;1;1;1;2;1

    But in domoticz it still gives me hardware error.

    Gateway version 1.5.

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NBM
      wrote on last edited by NBM
      #39

      How do i change the node number?
      It select node 2 all the time with new nodes?
      Skærmbillede 2016-01-10 kl. 17.48.26.png

      In the sketch they are set to AUTO.

      Im using standard sketch from the libery.

      1 Reply Last reply
      0
      • sundberg84S Offline
        sundberg84S Offline
        sundberg84
        Hardware Contributor
        wrote on last edited by sundberg84
        #40

        Change: gw.begin(incomingMessage, AUTO, true);
        To: gw.begin(incomingMessage, 3, true); (If you want 3 as node id)

        Controller: Proxmox VM - Home Assistant
        MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
        MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
        RFLink GW - Arduino Mega + RFLink Shield, 433mhz

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hugo_pn
          wrote on last edited by
          #41

          Made a test (with the external antenna on Gateway) the other day and this is what happens.

          I put the nrf24 with the external antenna attached to the Nano and Upload the Serial Gateway Scetch onto it.

          Ran The Serial Monitor and get this

          0;0;3;0;9;gateway started, id=0, parent=0, distance=0

          0;0;3;0;14;Gateway startup complete.

          I remove it from the PC, attach it to the Raspberry Pi I give two switch commands that work, then at the third attempt the message comes to life "Error sending switch command, check device/hardware !"

          2016-01-06 01:04:25.708 MySensors: Using serial port: /dev/ttyUSB0

          2016-01-06 01:04:27.186 MySensors: Gateway Ready...

          2016-01-06 01:04:27.262 MySensors: Gateway Version: 1.5

          2016-01-06 01:04:28.329 Hardware Monitor: Fetching data (System sensors)

          2016-01-06 01:04:56.024 User: admin initiated a switch command

          2016-01-06 01:04:58.436 Hardware Monitor: Fetching data (System sensors)

          2016-01-06 01:05:05.599 User: admin initiated a switch command

          2016-01-06 01:05:28.560 Hardware Monitor: Fetching data (System sensors)

          Back to PC this is what I get.

          0;0;3;0;9;radio init fail

          After a few minutes It's OK again like the beginning.

          Thanks

          1 Reply Last reply
          0
          • sundberg84S Offline
            sundberg84S Offline
            sundberg84
            Hardware Contributor
            wrote on last edited by sundberg84
            #42

            It (radio init fail) means that when you power it up (connecting it back to PC) it cant initialise radio.
            Mostly this is = check wires and/or power issues.

            Actions:
            Check wires, check wires and check wires :)
            Try powering your nano without the relay attached if possible (and see if you get Radio Init fails)
            If not - power your relay seperatly if possible (relay often create interferance with radio).

            Controller: Proxmox VM - Home Assistant
            MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
            MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
            RFLink GW - Arduino Mega + RFLink Shield, 433mhz

            H 1 Reply Last reply
            0
            • sundberg84S sundberg84

              It (radio init fail) means that when you power it up (connecting it back to PC) it cant initialise radio.
              Mostly this is = check wires and/or power issues.

              Actions:
              Check wires, check wires and check wires :)
              Try powering your nano without the relay attached if possible (and see if you get Radio Init fails)
              If not - power your relay seperatly if possible (relay often create interferance with radio).

              H Offline
              H Offline
              hugo_pn
              wrote on last edited by
              #43

              @sundberg84

              Thanks for the reply, the thing is that I'm powering the Nano via USB from the raspberry Pi (serial Gateway with the external antenna).
              The wires I don't think are the problem because it works with the integrated antenna.

              Can I power Up the Nano with the Raspbery Pi USB and a 5V Transformer with out burning everything?

              From what I remember, parallel tension doesn't sum up, but the current does. Wright?

              Will I damage everything, including the Raspberry?

              Thanks

              1 Reply Last reply
              0
              • sundberg84S Offline
                sundberg84S Offline
                sundberg84
                Hardware Contributor
                wrote on last edited by
                #44

                Sorry i missunderstood you, you are talking about the gateway, not the node with the relay right?
                If so, you dont need to power it seperetaly....

                Start with checking your wires...

                Controller: Proxmox VM - Home Assistant
                MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jloc
                  wrote on last edited by
                  #45

                  Hello friends:
                  Happens to me the same error " Error sending command switch , check device / hardware ! " when I update the device status from the application. HOWEVER from the device button it works well.
                  I tested with serial GW (internal GPIO ) and GW LAN , with the same results.
                  The traces of the device and the GW are:

                  Device type: light node: 3 child: 6

                  Command Msg GW Msg Device
                  On button 3; 6; 1; 0; 2; 1; send 3-3-2-0 s=6,c=1,t=2,pt=2,l=2,sg=0,st=ok:1
                  read: 0-2-3 s=6,c=1,t=2,pt=2,l=2,sg=0:1
                  This is an ack from gateway
                  Incoming change for sensor:6 , New status: 1
                  On Domoticz 3; 6; 1; 1; 2; 1; read: 0-2-3 s=6,c=1,t=2,pt=0,l=2,sg=0:1
                  send 3-3-2-0 s=6,c=1,t=2,pt=0,l=2,sg=0,st=ok:1
                  This is an ack from gateway
                  Incoming change for sensor:6 , New status: 1
                  Off button 3; 6; 1; 0; 2; 0; send 3-3-2-0 s=6,c=1,t=2,pt=2,l=2,sg=0,st=ok:0
                  read: 0-2-3 s=6,c=1,t=2,pt=2,l=2,sg=0:0
                  This is an ack from gateway
                  Incoming change for sensor:6 , New status: 0
                  Off Domoticz 3; 6; 1; 1; 2; 0; read: 0-2-3 s=6,c=1,t=2,pt=0,l=2,sg=0:0
                  send 3-3-2-0 s=6,c=1,t=2,pt=0,l=2,sg=0,st=ok:0
                  This is an ack from gateway
                  Incoming change for sensor:6 , New status: 0

                  A Someone comes up with an idea?

                  1 Reply Last reply
                  0
                  • sundberg84S Offline
                    sundberg84S Offline
                    sundberg84
                    Hardware Contributor
                    wrote on last edited by
                    #46

                    This might be useful: http://www.domoticz.com/forum/viewtopic.php?f=42&t=8910&p=61791&hilit=switch#p61791

                    Controller: Proxmox VM - Home Assistant
                    MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                    MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                    RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                    1 Reply Last reply
                    0
                    • N Offline
                      N Offline
                      NBM
                      wrote on last edited by
                      #47

                      I have solved the problem. I changes power supply and now it works.

                      Can someone recommend some power supply?

                      H 1 Reply Last reply
                      0
                      • N NBM

                        I have solved the problem. I changes power supply and now it works.

                        Can someone recommend some power supply?

                        H Offline
                        H Offline
                        hugo_pn
                        wrote on last edited by
                        #48

                        @sundberg84 Thanks for the reply.

                        @NBM

                        That's great news for all of US with this issue. With how many Amp's are you feeding the Arduino now?

                        Regarding the power supply, as @sundberg84 has said " Here is a great discussion: http://forum.mysensors.org/topic/1607/safe-in-wall-ac-to-dc-transformers"

                        Chears

                        1 Reply Last reply
                        0
                        • P Offline
                          P Offline
                          PostaanErik
                          wrote on last edited by
                          #49

                          I have similar issues with the Relay Actuator and Domoticz

                          I’m using MySensors 1.5, Serial gateway and domoticz on a windows machine.
                          Currently latest version: domoticz-win32-2_4078
                          Working with the standard provided arduino examples.

                          I cannot get Domoticz controlling the relay. The status is presented in domoticz when I use the RelayWithButtonActuator and press the button

                          Hardware is detected in Domoticz, devices are showing up (other devices like pressure/humidity are working fine).

                          I used multiple Arduino pro’s with different NRF’s + capacitator.
                          Disable Ack results in an error when trying to Switch via Domoticz

                          The serial output of the RelayWithButtonActuator looks like this:

                          send: 0-0-0-0 s=255,c=0,t=18,pt=0,l=5,sg=0,st=ok:1.5.1
                          send: 0-0-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
                          repeater started, id=0, parent=0, distance=0
                          send: 0-0-0-0 s=255,c=3,t=11,pt=0,l=14,sg=0,st=ok:Relay & Button
                          send: 0-0-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
                          send: 0-0-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:

                          When I press the button attached to the arduino:

                          This is an ack from gateway
                          Incoming change for sensor:1, New status: 0
                          send: 0-0-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:1
                          read: 0-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0:1
                          This is an ack from gateway
                          Incoming change for sensor:1, New status: 1

                          Any help or a working arduino Sketch would be appreciated.

                          Thanks

                          Erik

                          1 Reply Last reply
                          0
                          • sundberg84S Offline
                            sundberg84S Offline
                            sundberg84
                            Hardware Contributor
                            wrote on last edited by
                            #50

                            The logs look ok, doesnt the relay switch when you get this?

                            Incoming change for sensor:1, New status: 0
                            send: 0-0-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:1
                            read: 0-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0:1
                            This is an ack from gateway
                            Incoming change for sensor:1, New status: 1
                            

                            If not My guess its a power problem with the relay.

                            Controller: Proxmox VM - Home Assistant
                            MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                            MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                            RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                            1 Reply Last reply
                            0
                            • P Offline
                              P Offline
                              PostaanErik
                              wrote on last edited by
                              #51

                              Yes it is switching, but initiated from the attached button

                              1 Reply Last reply
                              0
                              • sundberg84S Offline
                                sundberg84S Offline
                                sundberg84
                                Hardware Contributor
                                wrote on last edited by sundberg84
                                #52

                                But not working from Domoticz and you get "Error sending command to switch" ?
                                Then nothing in the logs i guess when you try to initiate the command from Domoticz?

                                Its a trend here.. dont know if that is domoticz or MySensors but if you dont see anything in GW log trying to initiate the command from Domoticz I would ask this question in the Domoticz forum because then its a issue there.

                                Controller: Proxmox VM - Home Assistant
                                MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                                MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                                RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                                1 Reply Last reply
                                0
                                • Cliff KarlssonC Offline
                                  Cliff KarlssonC Offline
                                  Cliff Karlsson
                                  wrote on last edited by
                                  #53

                                  I am not very skilled at these things but I had the same problem for a long time and the only solution I found was to disable ack in domoticz.

                                  select hardware in the hardware/devices tab find the mysensors gateway and click setup.

                                  Try to find your node and deselect the ack box.

                                  1 Reply Last reply
                                  0
                                  • P Offline
                                    P Offline
                                    PostaanErik
                                    wrote on last edited by
                                    #54

                                    Thanks for the input, but this is not working for me :(

                                    1 Reply Last reply
                                    0
                                    • P Offline
                                      P Offline
                                      PostaanErik
                                      wrote on last edited by
                                      #55

                                      Small Update: seems that everything "sending" from domoticz is not received at the nodes.
                                      When monitoring the serial from relay, dimmer, rgb....

                                      when i tick devices in domoticz, a sensor is just not receiving:

                                      send: 31-31-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.1
                                      send: 31-31-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
                                      sensor started, id=31, parent=0, distance=1
                                      send: 31-31-0-0 s=255,c=3,t=11,pt=0,l=14,sg=0,st=ok:Relay & Button
                                      send: 31-31-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
                                      send: 31-31-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:

                                      1 Reply Last reply
                                      0
                                      • H Offline
                                        H Offline
                                        hugo_pn
                                        wrote on last edited by hugo_pn
                                        #56

                                        Hi all,

                                        After trying several things, I decided to try a downgrade on Domoticz going back to Domoticz V2.2563.

                                        Seems to be flawless, Suddenly everything is working fine for the past 6 days.

                                        What do you make of this?

                                        Thanks

                                        1 Reply Last reply
                                        0
                                        • F Offline
                                          F Offline
                                          flopp
                                          wrote on last edited by
                                          #57

                                          I read this post yesterday and today I solved it.
                                          My GW was restarting as soon as I was sending a command to a MYS node with dimmer child.
                                          I am using nRF PA-LNA, with extra power supply, PA_HIGH. Domoticz 3.8795, MYS 2.1.1. Nano as serial GW.
                                          Tried PA_LOW, new nRF but that didn't help.
                                          Today I found the solution, I disabled DEBUG in GW and now I can't reproduce any restarts.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          12

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular