Category Archives: Home-Assistant

Kello Smart Alarm Clock, Part 2

I’ve now had enough time to play with my Kello and I’ve done enough integrations to share some updates.

Now Kello doesn’t have an API per se, but there are a few commands that can be used to communicate with it.

This enabled me to created a Kello interface on Home-Assistant so I can control my Kello remotely. Bonus: I can even do this when I’m not home.

The main interface is this one:

And here are some of the functions that I’ve achieved:

  • When I stop the alarm, I then get greeted with the weather forecast for the day as well as estimated time to go to work
  • I can play various radio stations, change the volume
  • If for any reason the Kello loses WiFi connection, I get a notification email
  • When I leave home, or when I set the house mode to “Holidays”, all alarms get deactivated
  • When I reach home or when the house mode is no longer set to “Holidays”, all alarms are enabled

 

Here is a list of the commands I used to achieve the above:

Volume:

printf "\n0p40xx\r" | nc [Kello's IP Address] 4444

Where xx is the volume in hex (Dec from 0 to 100, so 0x00 to 0x64 in hex)

 

Muting all Alarms:

printf "\n0p231\r" | nc [Kello's IP Address] 4444

 

Unmuting all Alarms:

printf "\n0d231\r" | nc [Kello's IP Address] 4444

 

Play (online) Media:

printf "\n0p41uri:http\:\/\/cdn.us1.sunup.co\/files\/music\/sounds\/fireside.ogg\r" | nc [Kello's IP Address] 4444

 

Stop Media:

printf "\n0d41\r" | nc [Kello's IP Address] 4444

 

And don’t forget the IFTTT Integration for more automation, check my previous post on how do to this.




Kello Smart Alarm Clock

I have recently taken the plunge and jumped on the kickstarter wagon for the first time.
I successfully backed up a project called Kello.
And after months of anticipation, I finally received the product: a smart alarm clock:

Kello

Kello

Now not only does this alarm look good, but it’s also WiFi and IFTTT enabled and for me that was the major sales point. The plan was to integrate it with my automation setup.

I’ve only had it for about a month and already I’m really impressed with its prowess. The first thing I did was to connect it to IFTTT.

At the time of writing IFTTT is only a beta feature access needs to be requested ([email protected]). They are really responsive and I was granted access within 24h via the use of the TestFlight app on iOS

IFTTT integration currently offers 4 triggers:

  • alarm_start: triggers when an alarm starts ringing.
  • alarm_snooze: triggers when you press snooze.
  • alarm_stop: triggers when you stop the alarm.
  • alarm_soon_-1440, ..., alarm_soon_-120, alarm_soon_-6: the number on the right is the number of seconds before the alarm rings. Only use multiples of 60, up to 1440 seconds (24 minutes) before the alarm rings.

The other interesting bit is that the device can programatically be made to play online content with a one line piece of code:

printf "\n0p41uri:http\:\/\/cdn.us1.sunup.co\/files\/music\/sounds\/fireside.ogg\r" | nc 192.168.x.x 4444

The URL can be adjusted to play any online content (I’ve not tested all formats). The IP address needs to be the Kello’s IP address (best to set it to static on your router’s DHCP settings)

Armed with the above, I wanted to adjust my weather greeting script so as to play the audio on the Kello. The idea is to have the Kello play its set alarm sound to wake me up, then when I stop the alarm, a rule is triggered to play the weather forecast for the day (I pressed the stop button so I’m awake enough to pay attention to the forecast)

Here is how I did it.

  1. IFTTT:
    1. Go to http://www.ifttt.com/maker_webhooks.
    2. Press on the gear icon on the top right of your screen.
    3. Copy your webhook ID (the text after ‘http://make.ifttt.com/use/’).
  2. Home Assistant:
    1. Add the IFTTT integration to your configuration:
    2. Don’t forget to copy/save your webhook URL, you’ll need this later
    3. Add a new shell command to your configuration.yaml file. Replace the IP with your Kello’s IP address and replace the URL with the address of the weather forecast sound file you want to play (this is created and uploaded separately)
      shell_command:
      weather_on_kello: printf "\n0p41uri:http\:\/\/cdn.us1.sunup.co\/files\/music\/sounds\/fireside.ogg\r" | nc 192.168.x.x 4444
  3. Kello App:
    1. Go to the settings.
    2. Press ‘IFTTT’.
    3. Paste your webhook ID.
  4.  IFTTT:
    1. Create a new Applet.
    2. For the if THIS condition, choose Webhooks.
    3. Click on Receive a web request
    4. For the Event Name, choose one of the event as listed earlier on. I chose alarm_stop
    5. Click on Create trigger
    6. For the then THAT action, choose Webhooks.
    7. Click on Make a web request
    8. Enter the following details:
      1. URL: your Home Assistant IFTTT Webhook (you will get this when you setup the IFTTT Integration in HA, see 2.1 above)
      2. Method: POST
      3. Content Type: application/json
      4. Body: { “action”: “somekeywordgoeshere”}
    9. Click on Create action
  5. Home Assistant Automation:
    1. Create a new automation. The needed trigger will be:
  trigger:
    - platform: event
      event_type: ifttt_webhook_received
      event_data:
        action: somekeywordgoeshere

(*): To be able to receive events from IFTTT, your Home Assistant instance needs to be accessible from the web. This can be achieved by forwarding port 8123 from your router to the device running Home Assistant.

My next “project” is to mute or stop an alarm from playing if for any reason I’m not home so I don’t disturb anyone. Check this post to see how I did it




Syncing Home-Assistant.io and DomotiGa

Having tried Home-Assistant I can see how it can be really powerful once setup (and that’s probably where the issue lies, configuration is too much code driven with no UI at all).

However there are devices that are not yet supported by Home-Assistant (e.g. CurrentCost) and in addition, I can’t have both Home-Assistant and DomotiGa connected to my RFXTrx.

This means I’m looking to use both platforms and find a way to get them to talk to each other.
I already know how to send commands/updates to DomotiGa via JSON-RPC so that will be my first approach.

I’ve created a simple shell command that I use to update devices in DomotiGa:

shell_command:
  set_domotiga: curl -sS -X POST -H "Content-Type:application/json" -H "Accept:application/json" -d '{"jsonrpc":"2.0", "method":"device.set", "params":{"device_id":{{device_id}}, "valuenum":"{{valuenum}}", "value":"{{value}}"}, "id":122}' 192.168.0.24:9090

then in my automations, I call this function with the correct parameters. See below example for my Nest Thermostat (virtual) Device on DomotiGa:

- alias: Update Nest Status
  trigger:
    - platform: state
      entity_id: sensor.hallway_thermostat_hvac_state
  action:
    - service: shell_command.set_domotiga
      data_template:
        device_id: 122
        valuenum: 2
        value: '{{states.sensor.hallway_thermostat_temperature.state}}'

I’ve also tried to install Home-Assistant on my Raspberry Pi as I do like the Web interface, but it’s overkill and take too much overhead when I only need to monitor my GPIO ports. My own script is better in that effect.