Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Hacky Bond Integration ##
- #
- # Place the below directly in your configuration.yaml file.
- #
- # First make sure you have your BOND-Token, device ID's, and device command ID's by following the directions here:
- # http://docs-local.appbond.com/#section/Getting-Started
- #
- # All components will be set up with a base 'fan name'. This fan name will be used when calling the generic scripts
- # and this fan name will be used to check and update input_booleans, input_selects, and call shell_commands. I.E.:
- # 'master_fan' is my fan name, 'master_fan_pwr' is a shell command, 'master_fan_state' is an input boolean.
- ## Shell Commands to execute commands against a local BOND device
- #
- # Be sure to set the Bond Token, IP, device ID, and command ID's correctly.
- #
- # Create a shell command group for each named fan you have.
- shell_command:
- master_fan_light_toggle: 'curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.86.107/v2/devices/DEVICEID/commands/COMMANDID/tx -X PUT -d {}'
- master_fan_spd_low: 'curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.86.107/v2/devices/DEVICEID/commands/COMMANDID/tx -X PUT -d {}'
- master_fan_spd_medium: 'curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.86.107/v2/devices/DEVICEID/commands/COMMANDID/tx -X PUT -d {}'
- master_fan_spd_high: 'curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.86.107/v2/devices/DEVICEID/commands/COMMANDID/tx -X PUT -d {}'
- master_fan_pwr: 'curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.86.107/v2/devices/DEVICEID/commands/COMMANDID/tx -X PUT -d {}'
- livingroom_fan_light_toggle: 'curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.86.107/v2/devices/00000003/commands/COMMANDID/tx -X PUT -d {}'
- livingroom_fan_spd_low: 'curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.86.107/v2/devices/00000003/commands/COMMANDID/tx -X PUT -d {}'
- livingroom_fan_spd_medium: 'curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.86.107/v2/devices/00000003/commands/COMMANDID/tx -X PUT -d {}'
- livingroom_fan_spd_high: 'curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.86.107/v2/devices/00000003/commands/COMMANDID/tx -X PUT -d {}'
- livingroom_fan_pwr: 'curl -H "BOND-Token: xxxxxxxxxxxxxxxx" -i http://192.168.86.107/v2/devices/00000003/commands/COMMANDID/tx -X PUT -d {}'
- ## Fan and Fan Light States
- #
- # Be sure to have a state and light_state for each named fan.
- # Note that there is no initial value here - we want to retain the last value.
- #
- # If the fan state ever becomes out of sync with what home-assistant knows then
- # you can either modify this value to match the state, or use the fan controller
- # and change the fan to match what home-assistant knows.
- input_boolean:
- master_fan_state:
- name: Master Fan State
- master_fan_light_state:
- name: Master Fan Light State
- livingroom_fan_state:
- name: Livingroom Fan State
- livingroom_fan_light_state:
- name: Livingroom Fan Light State
- ## Fan Speed States
- #
- # Note that there is no initial value here - we want to retain the last value.
- # The first option will be the 'default' option when first started.
- input_select:
- master_fan_speed:
- name: Master Fan Speed
- options:
- - medium
- - low
- - high
- livingroom_fan_speed:
- name: Livingroom Fan Speed
- options:
- - medium
- - low
- - high
- ## Bond Scripts
- #
- # These scripts control turning the light and fan on and off, as well as setting the state.
- # They utilize the input_booleans and input_selects to ensure that we don't turn the fan
- # or the light on or off when we don't need to. This is important primarily when we're dealing
- # with devices that have toggle-only power buttons for either the light or fan operation.
- #
- # Use these scripts whenever you control a bond device to ensure that the states are stored correctly
- # in home-assistant.
- script:
- # Turn a Bond fan on only if it is currently off.
- # Sets the speed back to the last selected speed.
- #
- # Variables:
- # fan: The name of the fan you want to turn on.
- bond_fan_on:
- sequence:
- # Only proceed if the fan is currently off
- - condition: template
- value_template: "{{ is_state('input_boolean.' + fan + '_state', 'off') }}"
- # Return the fan to its previous speed
- - service: script.bond_fan_set_speed
- data_template:
- fan: "{{ fan }}"
- speed: "{{ states('input_select.' + fan + '_speed') }}"
- # Turn a Bond fan off only if it is currently on.
- #
- # Variables:
- # fan: The name of the fan you want to turn off.
- bond_fan_off:
- sequence:
- # Only proceed if the fan is currently on
- - condition: template
- value_template: "{{ is_state('input_boolean.' + fan + '_state', 'on') }}"
- # Set the fan off
- - service: input_boolean.turn_off
- data_template:
- entity_id: "{{ 'input_boolean.' + fan + '_state' }}"
- # Power off the fan
- - service_template: "{{ 'shell_command.' + fan + '_pwr' }}"
- # Set the speed of a Bond fan only if it is off or if the speed
- # is different than the currently selected speed.
- #
- # Variables:
- # fan: The name of the fan you want to turn on.
- # speed: The speed to set. Must be a value from the input_select.
- bond_fan_set_speed:
- sequence:
- # Only proceed if the fan is off OR the state is not the current speed
- - condition: template
- value_template: "{{ is_state('input_boolean.' + fan + '_state', 'off') or not is_state('input_select.' + fan + '_speed', speed) }}"
- # Only proceed if the given speed exists (sanity check)
- - condition: template
- value_template: "{{ speed in(states.input_select[fan+'_speed'].attributes.options) }}"
- # Set the fan on
- - service: input_boolean.turn_on
- data_template:
- entity_id: "{{ 'input_boolean.' + fan + '_state' }}"
- # Set the speed of the fan
- - service: input_select.select_option
- data_template:
- entity_id: "{{ 'input_select.' + fan + '_speed' }}"
- option: "{{ speed }}"
- # Call to set the speed of the fan
- - service_template: >
- {% if speed == 'low' %}
- {{ 'shell_command.' + fan + '_spd_low' }}
- {% elif speed == 'medium' %}
- {{ 'shell_command.' + fan + '_spd_medium' }}
- {% elif speed == 'high' %}
- {{ 'shell_command.' + fan + '_spd_high' }}
- {% endif %}
- # Turn a Bond fan light on only if it is currently off.
- #
- # Variables:
- # fan: The name of the fan with the light you want to turn off.
- bond_fan_light_on:
- sequence:
- # Only proceed if the fan light is currently off
- - condition: template
- value_template: "{{ is_state('input_boolean.' + fan + '_light_state', 'off') }}"
- # Set the fan light on
- - service: input_boolean.turn_on
- data_template:
- entity_id: "{{ 'input_boolean.' + fan + '_light_state' }}"
- # Toggle the fan light on
- - service_template: "{{ 'shell_command.' + fan + '_light_toggle' }}"
- # Turn a Bond fan light off only if it is currently on.
- #
- # Variables:
- # fan: The name of the fan with the light you want to turn off.
- bond_fan_light_off:
- sequence:
- # Only proceed if the fan light is currently on
- - condition: template
- value_template: "{{ is_state('input_boolean.' + fan + '_light_state', 'on') }}"
- # Set the fan light off
- - service: input_boolean.turn_off
- data_template:
- entity_id: "{{ 'input_boolean.' + fan + '_light_state' }}"
- # Toggle the fan light off
- - service_template: "{{ 'shell_command.' + fan + '_light_toggle' }}"
- ## Bond Fan Light Toggle Switches
- #
- # The ceiling fans I am using only support off/on or hold-to-dim.
- # To just give me the minimum functionality of an on-off light, I use a
- # template switch.
- switch:
- - platform: template
- switches:
- master_fan_light:
- value_template: "{{ is_state('input_boolean.master_fan_light_state', 'on') }}"
- turn_on:
- - service: script.bond_fan_light_on
- data:
- fan: 'master_fan'
- turn_off:
- - service: script.bond_fan_light_off
- data:
- fan: 'master_fan'
- livingroom_fan_light:
- value_template: "{{ is_state('input_boolean.livingroom_fan_light_state', 'on') }}"
- turn_on:
- - service: script.bond_fan_light_on
- data:
- fan: 'livingroom_fan'
- turn_off:
- - service: script.bond_fan_light_off
- data:
- fan: 'livingroom_fan'
- ## Bond Fan Lights
- #
- # Convert the light toggle switches into light components that only
- # support on|off functionality.
- light:
- - platform: switch
- name: Master Fan Light
- entity_id: switch.master_fan_light
- - platform: switch
- name: Livingroom Fan Light
- entity_id: switch.livingroom_fan_light
- ## Bond Fans
- #
- # Create a fan component using the input_boolean and input_select objects to
- # track state, and then utilize the scripts to turn the fan off, on, and set
- # the speed.
- fan:
- - platform: template
- fans:
- master_fan:
- friendly_name: "Master Fan"
- value_template: "{{ states('input_boolean.master_fan_state') }}"
- speed_template: "{{ states('input_select.master_fan_speed') }}"
- speeds:
- - 'high'
- - 'medium'
- - 'low'
- turn_on:
- - service: script.bond_fan_on
- data:
- fan: 'master_fan'
- turn_off:
- - service: script.bond_fan_off
- data:
- fan: 'master_fan'
- set_speed:
- - service: script.bond_fan_set_speed
- data_template:
- fan: 'master_fan'
- speed: "{{ speed }}"
- livingroom_fan:
- friendly_name: "Livingroom Fan"
- value_template: "{{ states('input_boolean.livingroom_fan_state') }}"
- speed_template: "{{ states('input_select.livingroom_fan_speed') }}"
- speeds:
- - 'high'
- - 'medium'
- - 'low'
- turn_on:
- - service: script.bond_fan_on
- data:
- fan: 'livingroom_fan'
- turn_off:
- - service: script.bond_fan_off
- data:
- fan: 'livingroom_fan'
- set_speed:
- - service: script.bond_fan_set_speed
- data_template:
- fan: 'livingroom_fan'
- speed: "{{ speed }}"
Add Comment
Please, Sign In to add comment