Announcement

Collapse
No announcement yet.

Syncing two devices

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Syncing two devices

    I have a Shelly1 wired to a switch, and a lamp at the other end of the room with a smart module connected to it. The switch is a momentary switch so the shelly alternates on/off with each press.

    The sole purpose of the Shelly is to signal to homeseer to turn on the lamp. The shelly in no way is wired to the lamp and cant control it directly.

    Here's my issue. The lamp can be controlled by other switches hence its important to keep the shelly in sync with the lamp or else the shelly will try to turn the lamp on when its already on and off when its already off.

    I wrote two events that basically say "turn lamp on when shelly is turned on" and turn "shelly on when lamp is turned on". Another two events for turning things off.

    So the problem is when another device turns the lamp on, the shelly is turned on too, but because the shelly is turned on, it sends another turn on request to the lamp. As far as I can tell, it stops at 2 turn on requests whenever the lamp is turned on or off. It isnt an infinite loop.

    So is this bad? Is there another way to keep these devices in sync thats more elegant? I tried the "sync" check box for both devices but it doesnt work.

    #2
    In the Event Advanced Options you can set the Event so it Cannot Re-run For ___ time. A more elegant solution, however, might be a Script or Node Reed flow which Toggles the lamp based on/off as opposed to assuming an On/Off. The EasyTrigger plugin may also be capable of doing this, but someone else, such as spud will have to speak of that capability as I do not use the plugin.
    Karl S
    HS4Pro on Windows 10
    1070 Devices
    56 Z-Wave Nodes
    104 Events
    HSTouch Clients: 3 Android, 1 iOS
    Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

    Comment


      #3
      Well, that advanced option setting seems to work fine, but my inner programmer in me says its a kludge. But it works, and I havent been able to come up with a better way, so it stays. Thanks for the tip, I didnt even know those event options were there.

      Comment


        #4
        Originally posted by dmagerl View Post
        Well, that advanced option setting seems to work fine, but my inner programmer in me says its a kludge. But it works, and I havent been able to come up with a better way, so it stays. Thanks for the tip, I didnt even know those event options were there.
        What is your trigger for those two events? If the trigger is "Device is set" then change it to "Device is changed".

        "Set" means to trigger the event whenever the device is set, even if it is already in that state. "Changed" will trigger only when the device is actually changed.

        That should stop the double triggering.

        If that does not make sense to you, please show us the actual events themselves.

        Comment


          #5
          I always wondered what the difference between those two triggers were. Thanks for explaining that. I'm using the "Device is changed" trigger.

          Comment


            #6
            BTW, Just for your information, this is my homebrew project. I need to keep the state of these buttons in sync with the lights they control.

            Click image for larger version

Name:	IMG_0175.JPG
Views:	264
Size:	75.5 KB
ID:	1475861

            Comment


              #7
              Those buttons look VERY familiar, dmagerl. I like the case. Did you 3D print that?

              Are you controlling that with an Arduino? Sending MQTT? I have a "Remote" which sends MQTT messages for HomeSeer virtual devices. I am almost finished converting the code over to a series of buttons and controller for my woodshop. Will control relays for lights, and also some other devices via MQTT/HomeSeer. For the wood shop project I am using what appears to be the same black buttons with blue ring. I have a custom PCB board which connects an Arduino Nano and CAN Bus module to the buttons as I am using CAN Bus to talk back tot he controller, but it would be a simple modification to make one for a NodeMCU instead. I also have one for 3 buttons. The controller is a Wemos/LOLIN D32 Pro which controls relays, sends and receives MQTT messages, and tells the button units to light the LED or not. Each button controls a "workstation" which is one or more relays or other devices based on a task or where I am. so for my table saw, 2 different lights are turned on. For my workbench, one of the lights used for the table saw is on and 2 others are as well. Any button in the are which controls a work station which is turned on will be lit. Long pressing any button but the bottom right button turns off all the lights regardless of states. The bottom right one will turn off everything, including the air filter.
              Click image for larger version  Name:	PXL_20210524_131029937.jpg Views:	0 Size:	46.3 KB ID:	1475989
              Click image for larger version  Name:	PXL_20210517_155053930.jpg Views:	0 Size:	141.8 KB ID:	1475992

              Click image for larger version  Name:	PXL_20210517_160229280.jpg Views:	0 Size:	89.1 KB ID:	1475991

              The CAN Bus module has pins as well as the blue wire terminals for the same connection. The blue wire terminals will be removed for mounting. But in a pure MQTT version, the CAN Bus module is not needed.
              Karl S
              HS4Pro on Windows 10
              1070 Devices
              56 Z-Wave Nodes
              104 Events
              HSTouch Clients: 3 Android, 1 iOS
              Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

              Comment


                #8
                Originally posted by dmagerl View Post
                I have a Shelly1 wired to a switch, and a lamp at the other end of the room with a smart module connected to it. The switch is a momentary switch so the shelly alternates on/off with each press.

                The sole purpose of the Shelly is to signal to homeseer to turn on the lamp. The shelly in no way is wired to the lamp and cant control it directly.

                Here's my issue. The lamp can be controlled by other switches hence its important to keep the shelly in sync with the lamp or else the shelly will try to turn the lamp on when its already on and off when its already off.
                This problem looks pretty simple to me, so I must be missing something.

                I'm not familiar with your device, and your operation description leaves me a little confused. I think you are describing one of these two possibilities:

                A: You press and release the Shelly button. If it was previously on, it is now off. If it was off, it is now on.
                B: You press the Shelly button. While the button is being pressed, the device reports it is on. When you release the button, the device reports that it is off.

                For either of these possibilities, I would use a single event that handles button presses on your Shelly:
                If the Shelly functions as possibility A, then the event is:
                IF shelly1 has a value that just changed
                THEN EasyTrigger: Toggle lamp
                If the Shelley functions as possibility B, then the event is:
                IF shelly1 changes and becomes Off
                THEN EasyTrigger: Toggle lamp

                The advantage of the toggle command: When you press the Shelly button, you don't really care what the status of the lamp is, you just want to change it.

                Hope this helps.

                Comment


                  #9
                  ksum

                  I bought that case from here:
                  https://www.homecontrols.com/Simply-...cessory-SAZTP2

                  Your project looks great! But both 3D printing and custom electronics are way beyond my abilities so I settled for buying off the shelf components.

                  Crammed into my case are two Shelly2.5s. That gives me 4 buttons.

                  But! Great minds think alike! I did a wall mounted version too that looks much like yours. It has one shellyi3 in it which gives me buttons with short press, double press, triple press, long/short press and short/long press capabilities. I have it set up for a short press turns on and a double press turns off. It talks back to Homeseer via MQTT. I used the smaller buttons because they come in different colors. I could only find the big buttons from Amazon in blue. So now my house has a red room, blue room, green room and yellow room :-)


                  Click image for larger version

Name:	IMG_0189a.jpg
Views:	248
Size:	102.8 KB
ID:	1484874
                  The table top controller has LEDs that light to indicate the state of the lamp being controlled, hence the need to keep things in sync. The wall mount version just has the LEDs permanently lit for a night light and because it looks cool.

                  Comment


                    #10
                    I didn't 3D print anything. That is an blank faceplate that I drilled. I did get the board printed, which cost me a few dollars, but not much. Under $20 US for 10.

                    I also have a simple version which just send MQTT messages over wifi. It also received messages to keep the button lights in sync. I could change the code in that to allow for multiple press as well as long press commands. I am thinking about making this available as a kit.

                    Did you flash the Shellys with tasmota?

                    Karl S
                    HS4Pro on Windows 10
                    1070 Devices
                    56 Z-Wave Nodes
                    104 Events
                    HSTouch Clients: 3 Android, 1 iOS
                    Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                    Comment


                      #11
                      While I have a number of Tasmota devices, I use the Shellys with their OEM firmware. Its just so easy to use MQTT on a Shelly with OEM firmware..

                      I had a really tough time drilling the switch plates. I used bakelite plates and they just cracked if there was the slightest pressure from the drill. Fortunately, switch plates are cheap. I used a 12mm forstner drill bit. I used the bakelite plates because they're stiffer than vinyl plates and provided more rigidity.

                      Comment

                      Working...
                      X