Announcement

Collapse
No announcement yet.

Get Light Brightness Level in script

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

  • Get Light Brightness Level in script

    I would like to read the brightness level of a light in a script. I see JSON value pairs listed under the Jowihue tab.

    Code:
    LightGroup
    
    **************************** Object info *****************************
    {
    "name": "Living Room Sconces",
    "lights": [
    "11",
    "12",
    "10",
    "8"
    ],
    "action": {
    "on": true,
    "bri": 89,
    "hue": 0,
    "sat": 127,
    "ct": 0,
    "effect": "none",
    "xy": [
    0.0,
    0.0
    ]
    },
    "type": "LightGroup",
    "state": {
    "all_on": true,
    "any_on": true
    },
    "devicemembership": [],
    "etag": "f73ec6147edecaa062155aeda1682ff8",
    "scenes": [],
    "id": "2"
    }
    ************************* End Object info ***************************
    How can I access that JSON string from a script?

  • #2
    You cannot access the JSON through the plugin, but you can use scripting like hs.getdevicevalueex(), check the helpfile of HS for this. Or if you want to work with JSON, check the JSON helpfile of HS for this

    Wim
    -- Wim

    Plugins:RFXCOM, HSTouch Server, Squeezebox, BLGData, Restart, Jon00's Perfmon and Network monitor, WeatherXML, BLBackup, TenScripting, BC4, Pushover, PHLocation, JowiHue, Zwave, Sonos
    650 devices ---- 336 events ----- 40 scripts

    Comment


    • #3
      Maybe I am missing something or I configured it incorrectly. I adjusted the brightness level with a Hue remote just now yet the HS device status shows the light group off and the status time stamp is from yesterday. How does the plugin update HS device status/values?

      Click image for larger version

Name:	sconce_status.PNG
Views:	54
Size:	36.3 KB
ID:	1321310

      The advanced tab shows this:

      Click image for larger version

Name:	sconce_status_1.PNG
Views:	46
Size:	171.6 KB
ID:	1321311

      Obviously when I try hs.DeviceValueEx(773) it returns a zero value.

      When I look at the device Jowihue tab I see different values:

      Click image for larger version

Name:	sconce_status_3.PNG
Views:	46
Size:	46.2 KB
ID:	1321312

      I would think Value be set to 75? How does the plugin update the devices and groups? Does it use web sockets or does it poll?

      Thanks,
      Patrick

      Comment


      • #4
        Patrick,

        It depends on your configuration if it use polling or webhooks. If you are using a Philips Hue bridge the plugin does use polling, by the setting of refreshrate in the configuration page. Philips bridge will not send webhooks, so polling is the only option. If you are using a deCONZ gateway, (either the USB device ConBee or the PI RaspBee) webhooks are enabled and response can be a lot faster for especially sensors and lights/groups.

        If you are using the current production version of JowiHue, 2.0.3.3, then there is an issue in updating group devices. This will be resolved in the next version, But still for group devices the updating of values in action will show a delay when the command was given through another app.
        The current beta has this issue reolved already at this moment. I f you plan to use the beta, be aware this will be a one way only update, so have a backup of the homeseer daabase at hand!
        If you update single lights, you will see all is working fine for those.

        Wim
        -- Wim

        Plugins:RFXCOM, HSTouch Server, Squeezebox, BLGData, Restart, Jon00's Perfmon and Network monitor, WeatherXML, BLBackup, TenScripting, BC4, Pushover, PHLocation, JowiHue, Zwave, Sonos
        650 devices ---- 336 events ----- 40 scripts

        Comment


        • #5
          Wim,
          Thanks for your response. I am using an RPI deCONZ gateway. What would the typical delay be for updating group devices with the beta version? What I am trying to do is syncronize some Insteon and Zigbee device brightness levels.

          Thanks,
          Patrick

          Comment


          • #6
            Except for the all lights group (which is not handled as group by the gateway) almost immediatly.

            Wim
            -- Wim

            Plugins:RFXCOM, HSTouch Server, Squeezebox, BLGData, Restart, Jon00's Perfmon and Network monitor, WeatherXML, BLBackup, TenScripting, BC4, Pushover, PHLocation, JowiHue, Zwave, Sonos
            650 devices ---- 336 events ----- 40 scripts

            Comment


            • #7
              I installed the beta version. I now see an additional root HS device for each physical device but the behavior has not changed. The group device still does not change status when controlled externally. The individual lights change graphic status from off to on but
              Code:
              hs.DeviceValueEx(773)
              returns zero regardless of the actual state.
              Code:
              hs.DeviceVSP_GetStatus(773, hs.DeviceValue(773), ePairStatusControl.Status)
              always returns "off".

              When I look at the device status in Home Assistant which uses the deCONZ API as well, the device and group status change instantly when controlled externally.

              Comment


              • #8
                I have rechecked here with your script statements and also changed the group through another app, updates are coming through correctly and also the script is showing the expected values. So I am not seeing the same issue as you. Does the device visually change whil checking the manage devices page?
                -- Wim

                Plugins:RFXCOM, HSTouch Server, Squeezebox, BLGData, Restart, Jon00's Perfmon and Network monitor, WeatherXML, BLBackup, TenScripting, BC4, Pushover, PHLocation, JowiHue, Zwave, Sonos
                650 devices ---- 336 events ----- 40 scripts

                Comment


                • #9
                  Yes the graphic status for the individual lights changes but the group device status does not change. The status value and brightness slider for any of the devices does not change.

                  Comment


                  • #10
                    Don't know why it is working for me, but not for you. Could you create a trace for me, so I might see if something wrong is happening? Follow these steps to get me the inof I want:

                    1. Enable detailed tracing and log to file n the Configuration page of the plugin
                    2. Stop and start the plugin, so I can see initialisation of the plugin
                    3. switch all lights in your test group to on and check if the group device switches on once all lights are on
                    4. Switch the lights off and check if th group device follows up
                    5. With your external app, switch the group (or all light in the group) to on and check if the group device responds
                    6 Switch the goup device off again
                    7 disable detailed tracing and tracing to log
                    8. Send me the log file ( you'll find it in the Logs subdirectory of the HS installation location as JowiHue.log)

                    Send it to jowihue at ziggo dot nl?

                    Thanks,

                    Wim
                    -- Wim

                    Plugins:RFXCOM, HSTouch Server, Squeezebox, BLGData, Restart, Jon00's Perfmon and Network monitor, WeatherXML, BLBackup, TenScripting, BC4, Pushover, PHLocation, JowiHue, Zwave, Sonos
                    650 devices ---- 336 events ----- 40 scripts

                    Comment

                    Working...
                    X