Git Product home page Git Product logo

Comments (8)

ZeroOne3010 avatar ZeroOne3010 commented on June 26, 2024

Hello there! The daylight sensor is integrated into Hue motion sensors. Their official description says:

The Hue Motion sensor's integrated daylight sensor detects when there is still enough daylight so that lights do not turn on until you need them. If it's still too dark, adjust the light sensitivity of the sensor in the Philips Hue app to personalize when you'd like the motion sensor to activate.

I wonder if you'd be able to show me the raw JSON output of your bridge, when you fetch the sensors? In my case, for example, a daylight sensor looks like this:

	"1": {
		"state": {
			"daylight": false,
			"lastupdated": "2021-02-08T14:22:00"
		},
		"config": {
			"on": true,
			"configured": true,
			"sunriseoffset": 30,
			"sunsetoffset": -30
		},
		"name": "Daylight",
		"type": "Daylight",
		"modelid": "PHDL00",
		"manufacturername": "Signify Netherlands B.V.",
		"swversion": "1.0"
	}

from yetanotherhueapi.

fk0ff92 avatar fk0ff92 commented on June 26, 2024
{
    "name":"Daylight",
    "type":"Daylight",
    "state":{
        "daylight":null,
        "lastupdated":"none"
        },
    "swupdate":null,
    "config":{
        "on":true,"
        configured":false,
        "sunriseoffset":30,
        "sunsetoffset":-30
        }
        ,
    "modelid":"PHDL00",
    "manufacturername":"Signify Netherlands B.V.",
    "swversion":"1.0",
    "uniqueid":null,
    "recycle":null,
    "productname":null,
    "capabilities":null
}

from yetanotherhueapi.

fk0ff92 avatar fk0ff92 commented on June 26, 2024

This could be the reason, why there occurs a NPE, because "daylight" is null.
I don't have configured my sensors with the Philipps hue app, because I use Apple HomeKit.
It sounds like those daylight sensors are kind of "virtuell" sensors, which are configured by the Phillips hue app.
The ambient sensors in the hue motion sensors are working fine.

I was surprised, that so much config overload exists in my hue raw output. There are so much scenes from 3rd party apps and so much rules I never configured.

from yetanotherhueapi.

fk0ff92 avatar fk0ff92 commented on June 26, 2024

I woke up this morning and did some research in the hue app. Under Settings > Advanced > Home Location, you can set your location, since I did this, the Daylight sensor works. By the way, the -30 and 30 come from the setting under Home Location "sunrise and sunset". So the sensor is virtual and is calculated from the geo data. If someone doesn't enter a home location because they may not use the app 100% like I do, then your api will always run into the NPE. Thanks for your advice.

from yetanotherhueapi.

ZeroOne3010 avatar ZeroOne3010 commented on June 26, 2024

Great, thanks for your research! In the JSON data you posted there's the part "configured": false which is kind of revealing: the sensor just wasn't configured. There's not much one can do with such a sensor, is there? I'm inclined to think that it probably shouldn't throw an NPE but some more sensible exception instead, explaining what went wrong.

from yetanotherhueapi.

ZeroOne3010 avatar ZeroOne3010 commented on June 26, 2024

...or then again I might just return false and log an error. 🤔 I checked the official docs, and they do not mention the configured property at all, so I'm hesitant to use it. Maybe it's nicer to not crash and to just document this behavior.

from yetanotherhueapi.

ZeroOne3010 avatar ZeroOne3010 commented on June 26, 2024

Also, the piece I copied from their documentation seems to be wrong in this context: clearly the daylight sensor we are talking about here is built into the Bridge, it's not a part of any motion sensor. The motion sensors have what are called ambient light sensors, but their marketing material refers to them as daylight sensors, which is very confusing. 🤦‍♂️

from yetanotherhueapi.

ZeroOne3010 avatar ZeroOne3010 commented on June 26, 2024

This fix has now been released in version 2.1.0. An uninitialized daylight sensor will not throw an NPE anymore but will instead just return false.

from yetanotherhueapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.