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

Home Assistant #12

Open
neurosurgeon opened this issue Sep 21, 2024 · 3 comments
Open

Home Assistant #12

neurosurgeon opened this issue Sep 21, 2024 · 3 comments

Comments

@neurosurgeon
Copy link

Hi this is great. I was able to set up a docker container to fetch my Dragonfly data. How do I go about integrating this with Home Assistant?

@robbrad
Copy link
Owner

robbrad commented Sep 22, 2024

Once I get home I'll share my home assistant config. But its basically a rest sensor or rest switch

@robbrad
Copy link
Owner

robbrad commented Sep 23, 2024

I have the following in my configuration.yaml

rest_command:
  observatory_main_light_on:
    method: put
    url: 'http://192.168.10.14:7001/relay/3?state=closed'
  observatory_main_light_off:
    method: put  
    url: 'http://192.168.10.14:7001/relay/3?state=open'
  observatory_close_button_off:
    method: put
    url: 'http://192.168.10.14:7001/relay/1?state=open'
  observatory_close_button_on:
    method: put
    url: 'http://192.168.10.14:7001/relay/1?state=closed'
  observatory_open_button_off:
    method: put
    url: 'http://192.168.10.14:7001/relay/0?state=open'
  observatory_open_button_on:
    method: put
    url: 'http://192.168.10.14:7001/relay/0?state=closed'

The following line in configutation.yaml

rest: !include_dir_merge_list restful/rest/

Enables homeassistant/restful/rest/observatory.yaml

---
- resource: http://192.168.10.14:7001/all
  scan_interval: 10
  method: GET
  verify_ssl: false
  headers:
    accept: "application/json"
    content-type: "application/json"
  sensor:
    - name: "Roof Control Open"
      json_attributes_path: "$.relays[?(@.name == 'roof_control_open')]"
      value_template: "{{ 'Open' if value_json['relays'][0]['state'] == 'open' else 'Closed' }}"
      json_attributes:
        - "is_active"
        - "name"
        - "state"
    - name: "Roof Control Close"
      json_attributes_path: "$.relays[?(@.name == 'roof_control_close')]"
      value_template: "{{ 'Open' if value_json['relays'][1]['state'] == 'open' else 'Closed' }}"
      json_attributes:
        - "is_active"
        - "name"
        - "state"
    - name: "Observatory Main Light"
      json_attributes_path: "$.relays[?(@.name == 'obsy_main_light')]"
      value_template: "{{ 'Off' if value_json['relays'][3]['state'] == 'open' else 'On' }}"
      json_attributes:
        - "is_active"
        - "name"
        - "state"
    - name: "Observatory Open Limiter Sensor"
      json_attributes_path: "$.sensors[?(@.name == 'open_limiter')]"
      value_template: "{{ value_json['sensors'][0]['value'] }}"
      json_attributes:
        - "name"
        - "value"
    - name: "Observatory Closed Limiter Sensor"
      json_attributes_path: "$.sensors[?(@.name == 'closed_limiter')]"
      value_template: "{{ value_json['sensors'][1]['value'] }}"
      json_attributes:
        - "name"
        - "value"
    - name: "Observatory Cloudwatcher Sensor"
      json_attributes_path: "$.sensors[?(@.name == 'cloudwatcher')]"
      value_template: "{{ value_json['sensors'][2]['value'] }}"
      json_attributes:
        - "name"
        - "value"
    - name: "Observatory Tilt Sensor"
      json_attributes_path: "$.sensors[?(@.name == 'tilt_sensor')]"
      value_template: "{{ value_json['sensors'][3]['value'] }}"
      json_attributes:
        - "name"
        - "value"
    - name: "Observatory Is Horizontal Sensor"
      json_attributes_path: "$.sensors[?(@.name == 'is_horizontal')]"
      value_template: "{{ value_json['sensors'][7]['value'] }}"
      json_attributes:
        - "name"
        - "value"

I also have a scripts.yaml with

roof_close_script:
  alias: Roof Close Script
  sequence:
  - alias: Check Safe to Close
    condition:
    - condition: state
      entity_id: binary_sensor.observatory_telescope_tilt
      state: 'on'
    - condition: state
      entity_id: sensor.mount_status
      state: 'parked'
  - alias: Disable Roof Open Switch
    service: rest_command.observatory_open_button_off
    data: {}
  - alias: Wait for the open button to be off
    wait_template: '{{ is_state(''sensor.roof_control_open'', ''open'') }}'
    timeout: 15
  - alias: Enable Roof Switch
    service: rest_command.observatory_close_button_on
    data: {}
  - alias: Wait for the roof to be closed
    wait_for_trigger:
    - platform: state
      entity_id: binary_sensor.observatory_closed_limiter
      to: 'on'
  mode: single
  icon: mdi:arrow-down
roof_open_script:
  alias: Roof Open Script
  sequence:
  - alias: Check Safe to Open
    condition:
    - condition: state
      entity_id: binary_sensor.observatory_telescope_tilt
      state: 'on'
    - condition: state
      entity_id: sensor.mount_status
      state: 'parked'
  - alias: Disable Roof Close Switch
    service: rest_command.observatory_close_button_off
    data: {}
  - alias: Wait for the close button to be off
    wait_template: '{{ is_state(''sensor.roof_control_close'', ''open'') }}'
    timeout: 15
  - alias: Enable Roof Switch
    service: rest_command.observatory_open_button_on
    data: {}
  - alias: Wait for the roof to be open
    wait_for_trigger:
    - platform: state
      entity_id: binary_sensor.observatory_open_limiter
      to: 'on'
  mode: single
  icon: mdi:arrow-up

@robbrad
Copy link
Owner

robbrad commented Sep 23, 2024

I might post my home assistant config on this repo

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

No branches or pull requests

2 participants