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. Troubleshooting
  3. How do I change a variable in domoticz from a sensor-reading?

How do I change a variable in domoticz from a sensor-reading?

Scheduled Pinned Locked Moved Troubleshooting
5 Posts 3 Posters 4.1k Views 2 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.
  • Cliff KarlssonC Offline
    Cliff KarlssonC Offline
    Cliff Karlsson
    wrote on last edited by
    #1

    I have created a integer variable in domoticz that I want to change depending on a sensor reading. I just want to understand how this is done so my current sketch is not very useful.

    I have a Ultrasonic sensor that I want to use to update the custom variable in domotics.
    If range is over 100cm -> set domoticz variable value to "1"
    If range is over 200cm -> set domoticz variable value to "2"
    and so on...

    sundberg84S 1 Reply Last reply
    0
    • Cliff KarlssonC Cliff Karlsson

      I have created a integer variable in domoticz that I want to change depending on a sensor reading. I just want to understand how this is done so my current sketch is not very useful.

      I have a Ultrasonic sensor that I want to use to update the custom variable in domotics.
      If range is over 100cm -> set domoticz variable value to "1"
      If range is over 200cm -> set domoticz variable value to "2"
      and so on...

      sundberg84S Offline
      sundberg84S Offline
      sundberg84
      Hardware Contributor
      wrote on last edited by
      #2

      @Cliff-Karlsson - One way is LUA which is the only way I know. Might be something from the GUI as well?

      if ( commandArray["RangeSensor"] > "100" ) then
        uservariables['Variable:MyVar']= "1"
      

      (not tested)

      Check more here: https://www.domoticz.com/wiki/User_variables

      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
        #3

        @sundberg84 said in How do I change a variable in domoticz from a sensor-reading?:

        e way is LUA which is the only way I know. Might be something from the GUI as well?

        @sundberg84 thanks, I guess that I was unclear about the usage. I do not want to present a distance-sensor to domoticz. I want to use a distance-sensor and only present some sort of sensor that only recieves the current number from the sketch.

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

          I tried to make another example of what I want to do:

          I am experementing and have built a very simple sensors with two ir beams that is placed in a row near a door. When I walk through from one side it registers a variable+=1 and when I walk the other way it registers - =1. My plan is to use something similar to be able to register if a room is occupied and also the number of persons in that room.

          If I already have the sensor how do I integrate that functionality into domoticz? I guess the occupied/unoccupied part could be solved by the sensor itself by acting like a switch and report "on" or similar when number of occupants in the room is greater than zero. But it would be nicer if it was also possible to get the actual number of persons and maybe something other than a on/off switch - icon.

          And if I have a room with multiple doorways it will not work very well as I need to be able to have multiple sensors that can modify the same variable.

          Is there some way that I can add a custom variable in domoticz called for example "livingroom" and have sensors that update the same variable on change. Like : sensor 1-> livingroom +=1, Trigger some switch to livingroom occupied then sensor 2-> livingroom -=1, triggers the same switch to unoccupied.

          Is this possible? And how would I register those sensors to domoticz and what do I send to be able to modify the domoticz custom variable?

          AWIA 1 Reply Last reply
          0
          • Cliff KarlssonC Cliff Karlsson

            I tried to make another example of what I want to do:

            I am experementing and have built a very simple sensors with two ir beams that is placed in a row near a door. When I walk through from one side it registers a variable+=1 and when I walk the other way it registers - =1. My plan is to use something similar to be able to register if a room is occupied and also the number of persons in that room.

            If I already have the sensor how do I integrate that functionality into domoticz? I guess the occupied/unoccupied part could be solved by the sensor itself by acting like a switch and report "on" or similar when number of occupants in the room is greater than zero. But it would be nicer if it was also possible to get the actual number of persons and maybe something other than a on/off switch - icon.

            And if I have a room with multiple doorways it will not work very well as I need to be able to have multiple sensors that can modify the same variable.

            Is there some way that I can add a custom variable in domoticz called for example "livingroom" and have sensors that update the same variable on change. Like : sensor 1-> livingroom +=1, Trigger some switch to livingroom occupied then sensor 2-> livingroom -=1, triggers the same switch to unoccupied.

            Is this possible? And how would I register those sensors to domoticz and what do I send to be able to modify the domoticz custom variable?

            AWIA Offline
            AWIA Offline
            AWI
            Hero Member
            wrote on last edited by
            #5

            @Cliff-Karlsson domoticz allows you to create a virtual / dummy counter sensor. You can increment / decrement it from several other sensor events in a LUA script as mentioned by @sundberg84

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


            17

            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