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. Development
  3. Get Relay State

Get Relay State

Scheduled Pinned Locked Moved Development
4 Posts 2 Posters 3.2k Views 1 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.
  • M Offline
    M Offline
    mikeones
    wrote on last edited by
    #1

    Is there an options to get the state of a relay? The API shows there is a light status option but it looks like it only sets the state.

    V_LIGHT 2 Light status. 0=off 1=on

    Here is the part of the relay sketch I am looking at.

    void setRelayStatus(message_s message) {
    if (message.header.messageType==M_SET_VARIABLE &&
     message.header.type==V_LIGHT) {
     int incomingRelayStatus = atoi(message.data);
     // Change relay state
     digitalWrite(message.header.childId,  incomingRelayStatus==1?RELAY_ON:RELAY_OFF);
      // Write some debug info
      Serial.print("Incoming change for relay on pin:");
      Serial.print(message.header.childId);
      Serial.print(", New status: ");
      Serial.println(incomingRelayStatus);
     }
    }
    

    Is there something similar to the lock status variable for a relay?

    V_LOCK_STATUS 36 Set or get lock status. 1=Locked, 0=Unlocked

    1 Reply Last reply
    0
    • E Offline
      E Offline
      epierre
      Hero Member
      wrote on last edited by
      #2

      you should write the last k own status in a var and request the var on startuo

      z-wave - Vera -> Domoticz
      rfx - Domoticz <- MyDomoAtHome <- Imperihome
      mysensors -> mysensors-gw -> Domoticz

      M 1 Reply Last reply
      0
      • E epierre

        you should write the last k own status in a var and request the var on startuo

        M Offline
        M Offline
        mikeones
        wrote on last edited by mikeones
        #3

        @epierre What would that look like? I was thinking of sending back the status on request. Something like this.

        void setRelayStatus(message_s message) {
        	if (message.header.messageType==M_SET_VARIABLE &&
        		message.header.type==V_LIGHT) {
        		int incomingRelayStatus = atoi(message.data);
        		if incomingRelayStatus == 2 {
        			gw.sendVariable(message.header.childId, V_LIGHT, digitalRead(message.header.childId)); 
        		} else {
        			// Change relay state
        			digitalWrite(message.header.childId, incomingRelayStatus==1?RELAY_ON:RELAY_OFF);
        			// Write some debug info
        			Serial.print("Incoming change for relay on pin:");
        			Serial.print(message.header.childId);
        			Serial.print(", New status: ");
        			Serial.println(incomingRelayStatus);
        		}
        	}
        }
        
        1 Reply Last reply
        0
        • E Offline
          E Offline
          epierre
          Hero Member
          wrote on last edited by
          #4

          I don't know why you use a telay. Look at thr watermeter code, it uses the pattern I described above

          z-wave - Vera -> Domoticz
          rfx - Domoticz <- MyDomoAtHome <- Imperihome
          mysensors -> mysensors-gw -> Domoticz

          1 Reply Last reply
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          11

          Online

          12.0k

          Users

          11.2k

          Topics

          113.4k

          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