npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

homebridge-somneo

v1.6.1

Published

A Homebridge plugin to control Philips Somneo clocks.

Downloads

54

Readme

homebridge-somneo

What This Plugin Is

This is a plugin for homebridge. It allows for management of the Philips Somneo HF3670/60. Additionally, it provides sensor data from the clock.

How the Plugin Works

The Somneo Clock has a small HTTP server running inside with a limited API. Through Googling and trial-and-error, I've found commands that work to replicate the SleepMapper app.

This server is very low powered though and if you see error messages in your logs it's most likely that two connections were trying to be processed at once.

Conflicting Accessories

In the physical world, the Somneo clock is a single device. But in the HomeBridge world, it is multiple. For this reason, I've created the concept of Conflicting Accessories.

A Conflicting Accessory means an accessory that needs full control over a physical device. In the case of the Somneo clock, there are two physical devices:

  1. The LED light.
  2. The audio speaker.

If a program requires light, it will turn off all other devices that require light. If it requires audio it will turn off all that require audio.

Below, is a chart explaining what will be turned off (if on) when an accessory is turned on.

| | Main Light | Night Light | Sunset Program | RelaxBreathe Program | Audio | | --- | :---: | :----------: | :------------: | :------------------: | :---: | | Main LightTurns On | N/A | Turns Off | Turns Off | Turns Off | Unaffected | | Night LightTurns On| Turns Off | N/A | Turns Off | Turns Off | Unaffected | | Sunset Turns On | Turns Off | Turns Off | N/A | Turns Off | Turns Off | RelaxBreatheTurns On | Turns Off | Turns Off | Turns Off | N/A | Turns Off| | AudioTurns On | Unaffected | Unaffected | Turns Off | Turns Off | N/A

Installation

Before installing this plugin, you should install Homebridge using the official instructions.

Install via Homebridge Config UI X

  1. Search for Homebridge Somneo on the Plugins tab of Config UI X.
  2. Install the Homebridge Somneo plugin and use the form to enter your configuration.

Manual Installation

  1. Install this plugin using: sudo npm install -g homebridge-somneo --unsafe-perm.
  2. Edit config.json manually to add your information. See below for instructions on that.

Manual Configuration

Platform Schema

| Field | Required | Data Type | Description | Default Value | | ------| :------: | :--------: | ----------------------------- | :----------: | | platform | Yes | string | Must always be set to HomebridgeSomneo.| N/A | | name | Yes | string | Set the platform name for display in the Homebridge logs. | Homebridge Somneo | | somneos | Yes | object[] | An array of configurations for Somneo clocks | N/A | | pollingSeconds| No | number | Time in seconds for how often to ping the clock. | 30 (30000 milliseconds) |

Somneo Schema

| Field | Required | Data Type | Description | Default Value | | ------| :------: | :-------: | ----------------------------- | :-----------: | | name | Yes | string | The name of the clock. It will be used as a prefix for all of the accessories it exposes. | N/A | | host | Yes | string | IP address or hostname of the Somneo clock. | N/A | | sensors | Yes | object | Settings for sensors in the Somneo clock. | N/A | | lights | Yes | object | Settings for lights in the Somneo clock. | N/A | | switches | Yes | object | Settings for switches in the Somneo clock. | N/A | | audio | Yes | object | Settings for the audio device in the Somneo clock. | N/A |

Sensors Schema

| Field | Required | Data Type | Description | Default Value | | ------| :------: | :-------: | ----------------------------- | :-----------: | | humidity | Yes | object | Settings for the humidity sensor. | N/A | | lux | Yes | object | Settings for the lux (light) sensor. | N/A | | temperature | Yes | object | Settings for the temperature sensor. | N/A |

Humidity Schema

| Field | Required | Data Type | Description | Default Value | | ------| :------: | :-------: | ----------------------------- | :-----------: | | isEnabled | No | boolean | Determines whether or not to expose the humidity sensor. | true |

Lux Schema

| Field | Required | Data Type | Description | Default Value | | ------| :------: | :-------: | ----------------------------- | :-----------: | | isEnabled | No | boolean | Determines whether or not to expose the lux (light) sensor. | true |

Temperature Schema

| Field | Required | Data Type | Description | Default Value | | ------| :------: | :-------: | ----------------------------- | :-----------: | | isEnabled | No | boolean | Determines whether or not to expose the temperature sensor. | true |

Lights Schema

| Field | Required | Data Type | Description | Default Value | | ------| :------: | :-------: | ----------------------------- | :-----------: | | mainLight | Yes | object | Settings for the main (dimmable) light. | N/A | | nightLight | Yes | object | Settings for the (on/off) night light. | N/A |

MainLight Schema

| Field | Required | Data Type | Description | Default Value | | ------| :------: | :-------: | ----------------------------- | :-----------: | | isEnabled | No | boolean | Determines whether or not to expose the main light. | true |

NightLight Schema

| Field | Required | Data Type | Description | Default Value | | ------| :------: | :-------: | ----------------------------- | :-----------: | | isEnabled | No | boolean | Determines whether or not to expose the night light. | true |

Switches Schema

| Field | Required | Data Type | Description | Default Value | | ------| :------: | :-------: | ----------------------------- | :-----------: | | relaxBreathe | Yes | object | Settings for the RelaxBreathe Program switch. | N/A | | sunset | Yes | object | Settings for the Sunset Program switch. | N/A |

RelaxBreathe Schema

| Field | Required | Data Type | Description | Default Value | | ------| :------: | :-------: | ----------------------------- | :-----------: | | isEnabled | No | boolean | Determines whether or not to expose the RelaxBreathe Program switch. | true | | breathsPerMin| No| number | How many breaths you want to take per minute. | 4 (BPM converted to the Philips value 1) | | duration | No | number | How long the RelaxBreathe Program should run for. | 10 (minutes) | | guidanceType | No | number | What kind of guided RelaxBreathe program to run.Possible values:Light = 0Sound = 1 | 0 (Light) | | lightIntensity | No | number | How bright the RelaxBreathe Program be at its peak. The value is a percentage that will be converted to a number between 1 and 25. | 80 (80% converted to the the Philips API value 20) | | volume | No | number | How loud the RelaxBreathe Program should be at its peak. The value is a percentage that will be converted to a number between 1 and 25. | 48 (48% converted to the the Philips API value 12) |

Sunset Schema

| Field | Required | Data Type | Description | Default Value | | ------| :------: | :-------: | ----------------------------- | :-----------: | | isEnabled | No | boolean | Determines whether or not to expose the Sunset Program switch. | true | | duration | No | number | How long the Sunset Program should run for. | 30 (minutes) | | lightIntensity | No | number | How bright the Sunset Program be at the start. The value is a percentage that will be converted to a number between 1 and 25. | 80 (80% converted to the the Philips API value 20) | | colorScheme | No | string | What color pattern should play during the Sunset Program.Possible values:Sunny Day = '0'Island Red = '1'Nordic White = '2'Carribean Red = '3' | '0' (Sunny Day) | | ambientSounds | No | string | What sounds should play during the Sunset Program.Possible values:Soft Rain = '1'Ocean Waves = '2'Under Water = '3'Summer Lake = '4'No Sound = '0' | '1' (Soft Rain) | | volume | No | number | How loud the Sunset Program should be at the start. The value is a percentage that will be converted to a number between 1 and 25. | 48 (48% converted to the the Philips API value 12) |

Audio Schema

| Field | Required | Data Type | Description | Default Value | | ------| :------: | :-------: | ----------------------------- | :-----------: | | isEnabled | No | boolean | Determines whether or not to expose the Audio Device. | true | | favoriteInput | No | number | Numeric value specifying the input for the Somneo Audio to go to the first time its turned on in a session.After changing the input, the Somneo will go to the last used input.Possible values:FM Preset 1 = 1FM Preset 2 = 2FM Preset 3 = 3FM Preset 4 = 4FM Preset 5 = 5Auxiliary = 6 | 1 (FM Preset 1) |

Somneo Audio Device Note

The Somneo clock has 5 FM radio presets and an auxiliary input. To help accomodate this, an audio receiver called Somneo Audio is available. You can turn in on and it will default to FM Preset 1. Additionally, you can raise and lower the volume with the Remote widget in iOS/iPadOS's Control Center.

However, due the way that audio receivers are implemented in Homebridge, they must be exposed as an External Plugin. This means that the Somneo Audio will need to be onboarded separately from the other accessories.

Onboarding Instructions for Somneo Audio

  1. Select Add Accessory in the Home app.
  2. Then select I Don't Have a Code or Cannot Scan.
  3. Then the Somneo Audio receiver should show as an option. It should look like:

Config Examples

Simplest Configuration

This configuration will expose all items and use the default polling interval with the least work.

{
  "name": "Homebridge Somneo",
  "somneos": [
    {
      "name": "Master Bedroom Somneo",
      "host": "[INSERT_IP_ADDRESS_HERE]"
    }
  ],
  "platform": "HomebridgeSomneo"
}

Most Verbose Configuration

This configuration will expose all items with default values, but is very verbose. It is presented here to help visualize the JSON structure.

{
  "name": "Homebridge Somneo",
  "somneos": [
    {
      "name": "Master Bedroom Somneo",
      "host": "[INSERT_IP_ADDRESS_HERE]",
      "sensors": {
        "humidity": {
          "isEnabled": true
        },
        "lux": {
          "isEnabled": true
        },
        "temperature": {
          "isEnabled": true
        }
      },
      "lights": {
        "mainLight": {
          "isEnabled": true
        },
        "nightLight": {
          "isEnabled": true
        }
      },
      "switches": {
        "relaxBreathe": {
          "isEnabled": true,
          "breathsPerMin": 4,
          "duration": 10,
          "guidanceType": 0,
          "lightIntensity": 80,
          "volume": 48
        },
        "sunset": {
          "isEnabled": true,
          "duration": 30,
          "lightIntensity": 80,
          "colorScheme": 0,
          "ambientSounds": "1",
          "volume": 48
        }
      },
      "audio": {
        "isEnabled": true,
        "favoriteInput": 1
      }
    }
  ],
  "pollingSeconds": 30,
  "platform": "HomebridgeSomneo"
}

Future Plans

  • No support for sound sensor. HomeKit does not have a sound level sensor. I thought about having an motion sensor, but would need to know what sound level motion detected/not should be considered.
  • Better error handling. I am a Java developer by trade and am still learning Typescript :).

Recognition

Thanks to:

  • homebridge - For creating a great template to get started with.
  • fototeddy - For creating a Homebridge Somneo plugin that reads the sensors.
  • DeKnep - For creating a similar plugin in another platform and exposing endpoints for control.