Access Keys:
Skip to content (Access Key - 0)
 

HTTP switch

Daniel Berenguer

On Apr 18, 2012 19:25

Hi, I'm now trying to make a switch work on my panel. My switch is attached to a sensor and I know that this sensor works because I've placed a label attached to this sensor and it's showing the correct value. However, the panel switch always displays "OFF". What is this switch expecting to get as a value? I've tried with "ON", "on", "1" but nothing works. As result, each time I press the switch an ON command is sent.

Thanks again!!

Daniel.

 
Labels:
Participants: Daniel Berenguer , Marcus Redeker
  1. Apr 19, 2012

    Marcus Redeker says:

    In general for a switch you need a "on" command to turn device on, a "off" comma...

    In general for a switch you need a "on" command to turn device on, a "off" command to turn device off and a "status" command which returns the active states as string "on" or "off". The status command has to be used for the switch sensor.

    If you can only turn the switch on and it does not reflect the new state, the device does not update the sensor. You will probably have to configure your status command with a fast polling interval (mayve 1 second) to have a quick feedback.

    1. Apr 19, 2012

      Daniel Berenguer says:

      Thanks Marcus. That's exactly what I've done but the switch sensor never displa...

      Thanks Marcus.

      That's exactly what I've done but the switch sensor never displays the correct value. On the other hand, I have a label that reflects the value correctly. I'm using a "custom" sensor for both the switch and the label. No mapping.

      1. Apr 19, 2012

        Marcus Redeker says:

        For the switch to work properly you have to use a "switch" sensor.

        For the switch to work properly you have to use a "switch" sensor.

        1. Apr 20, 2012

          Daniel Berenguer says:

          I tried that too... without success. A label attached to a custom sensor is dis...

          I tried that too... without success.

          A label attached to a custom sensor is displaying ON/OFF values correctly. However, a switch sensor (switch or custom) always displays OFF... I've tried with sending on/off in both lower case and upper case... just in case

          I've also tried to bind an image to each state of the button but same result. The off image stays forever there, regardless of the value returned by the HTTP request.

          Thanks again.

          1. Apr 20, 2012

            Marcus Redeker says:

            If your status command returns "on" or "off" and you use that inside a switch se...

            If your status command returns "on" or "off" and you use that inside a switch sensor it should work.
            No custom sensor needed at all. Also for a label you can use switch sensor.

            1. Apr 20, 2012

              Daniel Berenguer says:

              ... Also for a label you can use switch sensor... Tested that too but "N/A" is ...

              ... Also for a label you can use switch sensor...

              Tested that too but "N/A" is always displayed. The following are my settings:

              Switch Sensor:
              Name: SWITCH_SENSOR
              Command: Get_state
              Type: switch

              Custom Sensor:
              Name: CUSTOM_SENSOR
              Command: Get_state
              Type: custom

              Command:
              Name: Get_state
              Protocol: HTTP
              URL: http://localhost:8001/state.txt
              Polling interval: 1s

              Attaching CUSTOM_SENSOR to a label works well. However, attaching SWITCH_SENSOR makes the label display "N/A" all the time.

              Sorry to bother you again

              1. Apr 20, 2012

                Marcus Redeker says:

                When you assign a switch sensor to a label you have to define text for "on" and ...

                When you assign a switch sensor to a label you have to define text for "on" and "off".
                Did you do that?
                Also try to only have switch sensor and remove custom sensor completely.

                1. Apr 20, 2012

                  Daniel Berenguer says:

                  Yes, I've assigned a text for each state. I've also deleted the custom sensor as...

                  Yes, I've assigned a text for each state. I've also deleted the custom sensor as you suggest but the problem persists.

                  FYI, I have a screen displaying temperatures and humidities, using custom sensors attached to labels. Should I remove them too?

                  Thanks again for the great support!!

                  1. Apr 20, 2012

                    Marcus Redeker says:

                    Hmm, weird, it should work. You can try with a new configuration and only the co...

                    Hmm, weird, it should work.
                    You can try with a new configuration and only the command and sensor that has the problem.
                    You can also email me your openremote.zip file. marcus (at) openremote (dot) org

                    1. Apr 21, 2012

                      Daniel Berenguer says:

                      Thanks a lot Marcus. Noob question: how can I create a new config without loosi...

                      Thanks a lot Marcus.

                      Noob question: how can I create a new config without loosing my current one? I know I can save it in form of zip file but then, how can I reopen it from the online designer?

                      1. Apr 21, 2012

                        Marcus Redeker says:

                        We don't have a re-import yet, but it's on the todo list The easiest way would ...

                        We don't have a re-import yet, but it's on the todo list
                        The easiest way would be to create yourself a new account and just add the on/off/status commands and the switch sensor and the switch.

                        1. Apr 24, 2012

                          Daniel Berenguer says:

                          Problem solved. My first tries were sending "1" and "0" instead of "on" and "of...

                          Problem solved.

                          My first tries were sending "1" and "0" instead of "on" and "off" so that could never work. Then, I used a static file to supply on/off strings but, for some reason, that doesn't work for switches (it works for labels though). I've modified my application to reply with "on"/"off" strings instead and it works.

                          Thank you very much Marcus!

Adaptavist Theme Builder Powered by Atlassian Confluence