Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Home Assistant Integration #62

Closed
TomYoungs opened this issue Aug 17, 2024 · 3 comments · Fixed by #66
Closed

Add Home Assistant Integration #62

TomYoungs opened this issue Aug 17, 2024 · 3 comments · Fixed by #66

Comments

@TomYoungs
Copy link

Hey!

This might already be possible but would be nice to be able to control it via a home assistant dashboard, see when it's running etc, would fit into peoples automations as well which would be cool

Thanks,
Tom

@mwood77
Copy link
Owner

mwood77 commented Aug 19, 2024

The following comment has been superseded by #62 (comment).


Interesting idea - what kind of features would you expect from that?

You could actually interact with winderoo via home assistant automations right now, if you use the RESTful Command integration.

For example, I think this is all you'd need to get yourself up and running:

rest_command:
  winderoo_change_timer:
    url: "http://winderoo.local/api/timer"
    method: POST
    payload: "timerEnabled={{ timerEnabled }}"
    content_type: "application/x-www-form-urlencoded"

  winderoo_change_state:
    url: "http://winderoo.local/api/update"
    method: POST
    content_type: "application/json"
    payload: >
      {
        "tpd": "{{ tpd }}",
        "hour": "{{ hour }}",
        "minutes": "{{ minutes }}",
        "timerEnabled": "{{ timerEnabled }}",
        "action": "{{ action }}",
        "rotationDirection": "{{ rotationDirection }}",
        "screenSleep": {{ screenSleep | lower }}
      }

  winderoo_toggle_power:
    url: "http://winderoo.local/api/power"
    method: POST
    content_type: "application/json"
    payload: '{"winderEnabled": "{{ winderEnabled }}"}'

  winderoo_reset:
    url: "http://winderoo.local/api/reset"
    method: GET

  winderoo_get_status:
    url: "http://winderoo.local/api/status"
    method: GET
    content_type: "application/json"

Then you'd call it in an automation like:

# my automation

automation:
- alias: "Arrive at Work"
  trigger:
    platform: zone
    entity_id: device_tracker.my_device
    zone: zone.work
    event: enter
    action:
      - service: rest_command.winderoo_change_state
        data:
          tpd: "330"
          hour: "14"
          minutes: "30"
          timerEnabled: "1"
          action: "START"
          rotationDirection: "BOTH"
          screenSleep: false
    mode: single # you may or may not need this "mode: single" part

You could also create a sensor out of winderoo's /status endpoint, like so:

sensor:
  - platform: command_line
    name: Winderoo Status
    command: "curl -s http://winderoo.local/api/status | jq -r '.status'"
    scan_interval: 300  # Polls every 5 minutes

and use it in an automation like so:

automation:
  - alias: Check Winderoo Status and Notify
    description: "Call Winderoo status REST command and notify based on the status."
    trigger:
      - platform: time
        at: "08:00:00"
    action:
      - service: rest_command.winderoo_get_status
      - delay: "00:00:05"  # Wait for the command_line sensor to update
      - condition: template
        value_template: "{{ is_state('sensor.winderoo_status', 'STOPPED') }}"
      - service: notify.notify
        data:
          message: "Winderoo is currently stopped. Please check the device."
    mode: single # you may or may not need this "mode: single" part

Winderoo's API is documented as an OpenAPI Spec too, so that might be a bit easier for you to understand how to communicate with Winderoo programatically:

https://github.com/mwood77/winderoo/blob/main/openapi.yml

@mwood77
Copy link
Owner

mwood77 commented Oct 7, 2024

@TomYoungs @Rakura-cloud a proper home assistant integration over MQTT is coming. Most of the work required has been completed. Will likely release it in the next 48 hours.

see #66

@mwood77 mwood77 linked a pull request Oct 7, 2024 that will close this issue
6 tasks
@mwood77
Copy link
Owner

mwood77 commented Oct 8, 2024

✅ Home Assistant integration is live as part of release 3.0.0 (main branch)

You'll have to set a build flag and add your HA MQTT broker ip, username, and password. It's all written down here: flashing-your-microcontroller

You can see what you get in HA here: https://github.com/mwood77/winderoo/blob/main/docs/install-software.md#home-assistant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants