-
Notifications
You must be signed in to change notification settings - Fork 34
Home Assistant
The objective is to control the (non-)CVE fan within Home Assistant and show relevant sensors.
An example of the CVE unit with humidity and other sensors looks like this:
- The "medium" setting needs to be enabled (see main setup for CVE)
- MQTT broker must be running and reachable by the add-on
- MQTT must be activated in Home Assistant in configuration.yaml.
- MQTT must be activated in "MQTT" page on the add-on Web interface Applies to pre-2.3 versions only: change "State topic" to itho/state and "Itho Status topic" to itho/ithostatus
Recommendation is to leave all MQTT defaults as-is and only enter IP-address, username & password. Username and password must match the one used for MQTT broker, add-on and Home Assistant.
Note: MQTT brokers can run without credentials but it's recommended as a best practice to secure it even on the local network.
-
Install a broker (e.g. mosquitto) manually or via Home Assistant Add-ons. MQTT broker configuration is out of scope for this project as this is covered in many tutorials already.
-
Configure MQTT in Home Assistant by adding the following to configuration.yaml
# Example configuration.yaml entry which assumes MQTT_USERNAME and mysecretpassword are the credentials for the MQTT broker and created via mosquitto_passwd
mqtt:
broker: "IP_ADDRESS_BROKER"
username: "MQTT_USERNAME"
password: !secret MQTT_PASSWORD
Create or edit secrets.yaml and add:
MQTT_PASSWORD: mysecretpassword
- Restart Home Assistant and verify there is no connection error by checking the logs (Configuration / Logs).
Integrating the add-on with Home Assistant can be done via different options.
With MQTT Auto-discovery turned on in the "MQTT" menu of the add-on, the add-on should show up under Configuration -> Devices as a fan. Search for "Itho" and you should see 1 device. After clicking on it, you should see the fan registered as entity. Under "Device info" click on "MQTT Info" to see the received MQTT messages.
To manually add the fan, edit configuration.yaml and restart Home Assistant when done.
# Itho daalderop MV www.nrgwatch.nl
mqtt:
fan:
- name: nrg-itho-1_fan
unique_id: nrg-itho-1
json_attributes_topic: itho/ithostatus
device:
identifiers: "mv"
name: "Itho Box"
manufacturer: "Itho Daalderop"
model: "CVE-S ECO"
# ip adress of the wifi add-on
configuration_url: "http://192.168.4.37"
availability_topic: itho/lwt
state_topic: itho/state
# is de fan speed 0 dan is de state''off', bij groter dan 0 is die 'on'
state_value_template: "{% if (value | int) > 0 %}ON{% else %}OFF{% endif %}"
command_topic: itho/cmd
# de on/off knop in HA zet de fan speed op 0 (off) of op "low" (on)
command_template: '{% if value == "OFF" %}{ "speed":"0" }{% else %}{ "command":"low" }{% endif %}'
percentage_command_topic: itho/cmd
percentage_state_topic: itho/state
percentage_value_template: "{{ ((value | int)*100/255) | round(0) }}"
percentage_command_template: '{{ value * 2.54 }}'
preset_mode_command_topic: itho/cmd
preset_mode_command_template: >
{%- if value == "Low" %}{{"low"}}
{%- elif value == "Medium" %}{{"medium"}}
{%- elif value == "High" %}{{"high"}}
{%- elif value == "Timer 10min" %}{{"timer1"}}
{%- elif value == "Timer 20min" %}{{"timer2"}}
{%- elif value == "Timer 30min" %}{{"timer3"}}
{%- elif value == "Max" %}{{(100*255/100)|round(0)}}
{%- endif -%}
preset_modes:
- "Low"
- "Medium"
- "High"
- "Timer 10min"
- "Timer 20min"
- "Timer 30min"
- "Max"
preset_mode_state_topic: itho/state
preset_mode_value_template: >
{% set valuepct = 100*(value | int)/255|round(0) %}
{%- if valuepct >= 20 and valuepct <= 27 %}Low
{%- elif valuepct >= 46 and valuepct <= 53 %}Medium
{%- elif valuepct >= 77 and valuepct <= 83 %}High
{%- elif valuepct >= 97 %}Max
{%- endif -%}
Auto-discovery for non-CVE (E.g. Demandflow/QualityFlow/HRU-350) today does not work as there is no fan speed. Edit configuration.yaml and add the following and adjust where needed. Comment the preset_mode_command_template if you want to control the device via an RF remotes. This is useful when you don't have the CC1101 module. This example uses a virtual remote.
The config below assumes:
- Normalize keys is Off in the module’s System settings page
- Home Assistant MQTT Discovery is Off in the module's MQTT settings page.
mqtt:
fan:
- name: "Itho HRU 350 "
device:
identifiers: "mv"
name: "Itho Box"
manufacturer: "Itho Daalderop"
model: "Itho HRU 350"
# ip adress of the wifi add-on
configuration_url: "http://192.168.4.37"
unique_id: "Itho_hru_Fan"
state_topic: "itho/lwt"
state_value_template: "{% if value == 'online' %}ON{% else %}OFF{% endif %}"
command_topic: "itho/cmd"
preset_mode_state_topic: "itho/ithostatus"
preset_mode_command_template: "{ vremote: '{{ value }}'}"
preset_mode_value_template: >
{% set am = value_json['Actual Mode'] | int %}
{% if am == 1 %}
low
{% elif am == 2 %}
medium
{% elif am == 3 %}
high
{% elif am == 13 %}
timer
{% elif am == 24 %}
auto
{% elif am == 25 %}
autonight
{% else %}
{{ am }}
{% endif %}
preset_mode_command_topic: "itho/cmd"
preset_modes:
- "low"
- "medium"
- "high"
- "auto"
- "autonight"
- "timer1"
- "timer2"
- "timer3"
The above configuration only makes the fan available as entity. Additional sensors might be available to report CO2 (via Remote), Humidity percentage and temperature.
Add following to sensor configuration (e.g. sensors.yaml or configuration.yaml):
mqtt:
sensor:
- name: "ITHO Temperature"
state_topic: "itho/ithostatus"
unit_of_measurement: "°C"
value_template: "{{ value_json.temp }}"
device_class: "temperature"
unique_id: "itho_temp"
device:
identifiers: "mv"
To display humidity (if supported by the unit), add following to sensor configuration (e.g. sensors.yaml or configuration.yaml):
- name: "ITHO Humidity"
state_topic: "itho/ithostatus"
unit_of_measurement: "%"
value_template: "{{ value_json.hum }}"
device_class: "humidity"
unique_id: "itho_hum"
device:
identifiers: "mv"
MQTT home assistant setup for CO2 sensor (via Itho remote) If you have a remote that also shows the CO2 level, this can be visualised in Home Assistant.
mqtt:
sensor:
- name: Itho <unit> CO2
state_topic: "itho/remotesinfo"
unit_of_measurement: "ppm"
value_template: "{{ value_json.<unit>.co2 }}"
device_class: "carbon_dioxide"
unique_id: "itho_<unit>_co2"
device:
identifiers: "mv"
Replace with the name given in the Add-on RF Remotes page.
To ensure the correct parsing of JSON labels you can use the bracket notation.
ie. value_json['Fan speed (rpm)']
for the value of label 'Fan speed (rpm)'
.
This also works nested. For a JSON {"first level":{"nested level":10}}
the statement value_json['first level']['nested level']
would pass the value 10 to home assistant.
mqtt:
sensor:
- name: "ITHO rpm sensor"
state_topic: "itho/ithostatus"
unit_of_measurement: "rpm"
value_template: "{{ value_json['Fan speed (rpm)'] }}"
unique_id: "itho_rpm"
device:
identifiers: "mv"
While it is possible to add the sensors and fan via YAML to the dashboard, doing this via the UI is easier. To add the Entities card to your user interface, click the Lovelace menu (three dots at the top right of the screen) and then Edit Dashboard. Click the “Add Card” button in the bottom right corner and select Entities from the card picker. You can filter for them by typing 'itho'.
Some examples for integrating the fan and other data with Home Assistant
This assumes that the CVE Itho unit has a built-in humidity sensor
-----Bathroom humidity and increasing fan speed
- id: "Fan up when showering"
alias: fan UP when showering
description: Bathroom humidity and increasing fan speed
trigger:
- platform: template
value_template: "{{ is_state_attr('fan.itho_fan', 'hum', '50') }}"
for: "00:10:00" # only triggers if humidity is >50% for 10 minutes or more
condition: []
action:
- service: fan.set_percentage
target:
entity_id: fan.itho_fan
data:
percentage: 100
- wait_template: ''
timeout: '00:15:00' # trigger low speed after 15 minutes
continue_on_timeout: true
- service: fan.set_percentage
target:
entity_id: fan.itho_fan
data:
percentage: 33
mode: single
Non-CVE without Demandflow/Qualityflow don't have a built-in humidity sensor. This example uses a separate humidity sensor sensor.badkamer_humidity
It sets fan to high if humidity is 70% or higher for 1 minute. If humidity decreases to 60% or lower for 3 minutes, set preset to auto. The timeout ensures it goes to auto after 2 hours regardless of the current humidity.
alias: Itho - Badkamer
description: ''
trigger:
- platform: numeric_state
above: '70'
for:
hours: 0
minutes: 1
seconds: 0
entity_id: sensor.badkamer_humidity
action:
- service: fan.set_preset_mode
data:
preset_mode: high
target:
entity_id: fan.itho_hru_350
- wait_for_trigger:
- platform: numeric_state
below: '60'
for:
hours: 0
minutes: 3
seconds: 0
entity_id: sensor.badkamer2_humidity
timeout: '00:02:00'
- service: fan.set_preset_mode
data:
preset_mode: auto
target:
entity_id: fan.itho_hru_350
mode: single
- alias: "Set fan slider Itho F"
trigger:
platform: mqtt
topic: 'itho/state'
action:
service: input_number.set_value
data:
entity_id: input_number.itho_fan_nr
value: "{{ trigger.payload }}"
- alias: "Fan slider itho<description> moved"
trigger:
platform: state
entity_id: input_number.itho_fan_nr
condition:
condition: template
value_template: "{{ states('sensor.itho_status_<unit2>_fan') | int != states('input_number.itho_0b08_fan') | int }}"
action:
service: mqtt.publish
data:
topic: 'itho/cmd'
retain: true
payload: "{{ states('input_number.itho_fan') | int }}"
When showering (rising humidity) increase fan speed
To create a 3 button interface (scripts.yml)
#-----Mechanical ventilation presets
mv_preset_low:
alias: MV preset low
icon: mdi:fan-speed-1
sequence:
- service: fan.set_percentage
target:
entity_id: fan.itho_fan
data:
percentage: 33
mv_preset_medium:
alias: MV preset medium
icon: mdi:fan-speed-2
sequence:
- service: fan.set_percentage
target:
entity_id: fan.itho_fan
data:
percentage: 50
mv_preset_high:
alias: MV preset high
icon: mdi:fan-speed-3
sequence:
- service: fan.set_percentage
target:
entity_id: fan.itho_fan
data:
percentage: 100
The Lovelace part for using the buttons on the UI
- title: Mechanische ventilatie
type: entities
entities:
- entity: input_number.fan_itho_speed
name: Fan
icon: mdi:fan
- entity: sensor.fan_itho_state
- type: horizontal-stack
cards:
- type: button
show_name: false
show_state: false
icon_height: 75px
entity: script.mv_preset_low
tap_action:
action: call-service
service: script.turn_on
service_data:
entity_id: script.mv_preset_low
- type: button
show_name: false
show_state: false
icon_height: 75px
entity: script.mv_preset_medium
tap_action:
action: call-service
service: script.turn_on
service_data:
entity_id: script.mv_preset_medium
- type: button
show_name: false
show_state: false
icon_height: 75px
entity: script.mv_preset_high
tap_action:
action: call-service
service: script.turn_on
service_data:
entity_id: script.mv_preset_high