This is alternative option for integration of Switcher water heater in Home Assistant.
There are two existing components, both developed by tomerfi, for that:
- "switcher_aio" - Very old custom component and has issues with newer versions of HA.
- "switcher_kis" - Newer component, already part of official HA releases. However it has very limited functionality. Also some people report they are getting timeouts while trying to load it during HA startup.
In this solution we will be using Switcher water heater WebAPI, running in docker, developed also by tomerfi.
- Install and configure your Switcher device.
- Collect the following information from the device’s following NightRang3r instructions in the Switcher-V2-Python repository:
- ip_address
- phone_id
- device_id
- device_pass
- Install docker
Setup Switcher water heater WebAPI container in docker using its the documentation.
This is example of working Docker Compose (change to your values):
version: '2'
services:
switcher_webapi:
image: tomerfi/switcher_webapi:latest
container_name: switcher_webapi
hostname: switcher_webapi
restart: always
network_mode: bridge
ports:
- 8000:8000
environment:
CONF_DEVICE_IP_ADDR: <<your Switcher IP address>>
CONF_PHONE_ID: <<your phone ID>>
CONF_DEVICE_ID: <<your device ID>>
CONF_DEVICE_PASSWORD: <<your device password>>
CONF_THROTTLE: 1.0
Define RESTful commands in HA, to be used in scripts.
Change to your IP and port below.
rest_command:
switcher_turn_on:
url: http://192.168.1.1:8000/switcher/turn_on
method: "POST"
payload: '{"minutes": "{{ minutes }}"}'
switcher_turn_off:
url: http://192.168.1.1:8000/switcher/turn_off
method: "POST"
Define RESTful Sensor and other Template sensors depending on it in HA.
Change to your IP and port below.
sensor:
- platform: rest
resource: http://192.168.1.1:8000/switcher/get_state
name: Switcher WebAPI
json_attributes:
- state
- time_left
- auto_off
- power_consumption
- electric_current
value_template: 'OK'
- platform: template
sensors:
switcher_webapi_time_left:
friendly_name: "Time Left"
icon_template: mdi:timelapse
value_template: >-
{{ state_attr('sensor.switcher_webapi', 'time_left') }}
switcher_webapi_electric_current:
friendly_name: "Electric Current"
icon_template: mdi:flash
unit_of_measurement: A
value_template: >-
{{ state_attr('sensor.switcher_webapi', 'electric_current') }}
switcher_webapi_power_consumption:
friendly_name: "Power Consumption"
icon_template: mdi:flash
unit_of_measurement: kW
value_template: >-
{{ state_attr('sensor.switcher_webapi', 'power_consumption') }}
switcher_webapi_state:
friendly_name: "State"
icon_template: mdi:shower
value_template: >-
{{ state_attr('sensor.switcher_webapi', 'state') }}
Define Input Select in HA, to select the timings for the Turn On with timer script.
input_select:
switcher_timer_minutes_input_select:
name: Timer minutes
options:
- 15
- 30
- 45
- 60
Define scripts in HA for turning on the Switcher, with and without timers, and turning it off.
script:
switcher_turn_on_timer_script:
alias: On with Timer
sequence:
- service: rest_command.switcher_turn_on
data_template:
minutes: '{{ states("input_select.switcher_timer_minutes_input_select") }}'
- service: homeassistant.update_entity
entity_id: sensor.switcher_webapi
switcher_turn_on:
alias: Turn On
sequence:
- service: rest_command.switcher_turn_on
- service: homeassistant.update_entity
entity_id: sensor.switcher_webapi
switcher_turn_off:
alias: Turn Off
sequence:
- service: rest_command.switcher_turn_off
- service: homeassistant.update_entity
entity_id: sensor.switcher_webapi
Define Switch in HA, which uses the sensor and scripts we defined before.
switch:
- platform: template
switches:
switcher_webapi:
friendly_name: Boiler
icon_template: mdi:shower
entity_id: sensor.switcher_webapi
value_template: "{{ is_state_attr('sensor.switcher_webapi', 'state', 'on') }}"
turn_on:
service: script.turn_on
data:
entity_id: script.switcher_turn_on
turn_off:
service: script.turn_on
data:
entity_id: script.switcher_turn_off
This is it. All that is left to define a nice UI and use all the above entities. But this is for another guide.