jnthas / clockwise

do-it-yourself, full-featured and smart wall clock device
https://clockwise.page
MIT License
304 stars 39 forks source link

[Feature Request] Integration with Home Assistant #51

Open jorgeassuncao opened 1 year ago

jorgeassuncao commented 1 year ago

Is it possible to integrate the Clock with Home Assistant? Being based on ESPhome i believe it would be realy simple to do.

At the moment when trying to integrate it with HA this is the result

image

jnthas commented 12 months ago

Hi Jorge. This is an interesting feature that I didn't work yet. I agree that it won't be difficult to add it. For now, I think you can use the endpoints available on Clockwise to do a basic integration with Home Assistant https://clockwise.page/docs/api

karl0ss commented 9 months ago

@jorgeassuncao

I created 2 rest_command in my HA yaml

rest_command:
  clockwise_set_display_brightness:
    url: "http://<CLOCKIP>/set?displayBright={{ brightness }}"
    method: POST
  clockwise_restart:
    url: "http://<CLOCKIP>/restart"
    method: POST
    content_type: "application/x-www-form-urlencoded"

You can then execute the services using

service: rest_command.clockwise_set_display_brightness
data:
  brightness: 25
service: rest_command.clockwise_restart

I have then created automations tied into "day and night routines" that will execute the first rest command, setting the brightness to X, sleeping for 2 seconds, then executing the restart service.

Something like this


description: "Turn off clock at 11pm"
mode: single
trigger:
  - platform: time
    at: "23:00:00"
condition: []
action:
  - service: rest_command.clockwise_set_display_brightness
    data:
      brightness: 1
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: rest_command.clockwise_restart
    data: {}

Seems to give a nice way of turning the display on/off via an automation in HA