isalkind / homebridge-away-mode

Homebridge plugin that provides triggers to turn on and turn off lights to simulate occupancy.
MIT License
26 stars 5 forks source link

Sunrise/Sunset Offset in Actives Times for Sensor #12

Closed leftytennis closed 3 years ago

leftytennis commented 3 years ago

Hi, I have setup the global offset for sunrise/sunset, but I'd like to have an active time period for a specific sensor to be 15 minutes before sunrise until 15 minutes after sunrise.

Is this possible? If so, can you show me the syntax to use in the plugin config?

I tried this:

{
                    "name": "Bedroom Trigger",
                    "minOffTime": 3600,
                    "minOnTime": 180,
                    "maxOnTime": 300,
                    "activeTimesForSensor": [
                        {
                            "start": {
                                "sunrise": -30
                            },
                            "end": {
                                "sunrise": 30
                            },
                            "maxActivations": 3
                        }
                    ]
}

But receive the following error:

[7/15/2021, 2:03:48 PM] [Away Mode] MotionSensor: Bedroom Trigger
[7/15/2021, 2:03:48 PM] Error: 
    at toMs (/homebridge/node_modules/homebridge-away-mode/node_modules/hh-mm-ss/index.js:63:22)
    at Object.toS (/homebridge/node_modules/homebridge-away-mode/node_modules/hh-mm-ss/index.js:81:12)
    at AwayMode.computeSecondsFromMidnight (/homebridge/node_modules/homebridge-away-mode/index.js:212:32)
    at AwayMode.computeStartEndTimesForSensor (/homebridge/node_modules/homebridge-away-mode/index.js:233:34)
    at new AwayMode (/homebridge/node_modules/homebridge-away-mode/index.js:140:18)
    at /usr/local/lib/node_modules/homebridge/src/server.ts:350:50
    at Array.forEach (<anonymous>)
    at Server.loadAccessories (/usr/local/lib/node_modules/homebridge/src/server.ts:270:29)
    at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:162:12)

Thanks

isalkind commented 3 years ago

This is currently not possible. There is only a global offset for sunrise/sunset.

I can see where this is a reasonable use case to want. Let me look into adding a per-sensor offset. Give me a few days to poke around.

leftytennis commented 3 years ago

Awesome, thanks!

isalkind commented 3 years ago

@jt70471 I've pushed out a new release (1.6.1). Please give it a try.

Using the same example you gave above, you would configure it as:

{
                    "name": "Bedroom Trigger",
                    "minOffTime": 3600,
                    "minOnTime": 180,
                    "maxOnTime": 300,
                    "activeTimesForSensor": [
                        {
                            "start": "sunrise",
                            "end": "sunrise",
                            "maxActivations": 3
                        }
                    ],
                    "offset": {
                        "sunrise": -30,
                        "sunset": 30
                    }
}