Configuration
MQTT configuration for the central system Home Assistant. You can derive the logic for another system.
SWITCHLIGHTFANSENSORAIR
mqtt:
# SWITCHES
switch:
# TOGGLE SWITCH only one switch is always on and the other off
- name: "Blinds"
unique_id: "pyramidak_blinds"
state_topic: "blinds/switch1/state"
command_topic: "blinds/switch1/command"
# TWO SWITCHES each switch controls a different appliance
- name: "Living room heater"
unique_id: "pyramidak_heater_livingroom"
state_topic: "heater/switch1/state"
command_topic: "heater/switch1/command"
- name: "Rear speakers"
unique_id: "pyramidak_speakers_rear"
state_topic: "heater/switch2/state"
command_topic: "heater/switch2/command"
# ONE SWITCH CONTROLS BOTH, switches acts as one - both ON or OFF
- name: "Front and bass speakers"
unique_id: "pyramidak_speakers"
state_topic: "speakers/switch/state"
command_topic: "speakers/switch/command"
mqtt:
# LIGHTS
light:
# LIGHT DIMMER
- name: "Kitchen"
unique_id: "pyramidak_kitchen"
state_topic: "kitchen/switch1/state"
command_topic: "kitchen/switch1/command"
brightness_state_topic: "kitchen/brightness/state"
brightness_command_topic: "kitchen/brightness/command"
# LIGHT SWITCH second switch is light, first one is fan
- name: "Bathroom"
unique_id: "pyramidak_bathroom_light"
state_topic: "bathroom/switch2/state"
command_topic: "bathroom/switch2/command"
mqtt:
# FANS
fan:
- name: "Bathroom"
unique_id: "pyramidak_bathroom_fan"
state_topic: "bathroom/switch1/state"
command_topic: "bathroom/switch1/command"
mqtt:
# SENSORS
sensor:
# SENSOR DOOR
- name: "Toilet door"
unique_id: "pyramidak_toilet_door"
state_topic: "toilet/analog/state"
# SENSOR SWITCH
- name: "Toilet switch"
unique_id: "pyramidak_toilet_switch"
state_topic: "toilet/digital/state"
# SENSOR PIR
- name: "Hall movement"
unique_id: "pyramidak_hall_movement"
state_topic: "hall/digital/state"
# SENSOR TEMPERATURE AND HUMIDITY
- name: "Bathroom temperature"
unique_id: "pyramidak_mirror_temperature"
state_topic: "mirror/digital/state"
device_class: temperature
unit_of_measurement: '°C'
- name: "Bathroom humidity"
unique_id: "pyramidak_mirror_humidity"
state_topic: "mirror/digital2/state"
device_class: humidity
unit_of_measurement: '%'
# SENSOR LIGHT
- name: "Bathroom light"
unique_id: "pyramidak_mirror_light"
state_topic: "mirror/analog/state"
# SENSOR CURRENT
- name: "Washing machine current"
unique_id: "pyramidak_washingmachine_current"
state_topic: "washing-machine/analog/state"
# ONLINE
- name: "hall"
state_topic: "hall/status"
unique_id: "pyramidak_hall_status"
expire_after: 90
# FIRMWARE
- name: "hall"
state_topic: "hall/update/state"
unique_id: "pyramidak_hall_update"
# IP ADDRESS
- name: "hall"
state_topic: "hall/ip/state"
unique_id: "pyramidak_hall_ip"
mqtt:
# SENSORS
sensor:
# AIR QUALITY
- name: "Home air score"
unique_id: "pyramidak_home_score"
state_topic: "home/quality/number"
device_class: aqi
- name: "Home air quality"
unique_id: "pyramidak_home_word"
state_topic: "home/quality/word"
# LIGHT
- name: "Home light"
unique_id: "pyramidak_home_light"
state_topic: "home/light"
device_class: illuminance
unit_of_measurement: 'lx'
# CARBON DIOXIDE
- name: "Home carbon dioxide"
unique_id: "pyramidak_home_co2"
state_topic: "home/co2"
device_class: carbon_dioxide
unit_of_measurement: 'ppm'
# VOLATILE ORGANIC COMPOUNDS
- name: "Home TVOC"
unique_id: "pyramidak_home_tvoc"
state_topic: "home/tvoc"
device_class: volatile_organic_compounds
unit_of_measurement: 'ppb'
# TEMPERATURE
- name: "Home temperature"
unique_id: "pyramidak_home_temperature"
state_topic: "home/temperature"
device_class: temperature
unit_of_measurement: '°C'
# HUMIDITY
- name: "Home humidity"
unique_id: "pyramidak_home_humidity"
state_topic: "home/humidity"
device_class: humidity
unit_of_measurement: '%'
# ATMOSPHERIC PRESSURE
- name: "Pressure"
unique_id: "pyramidak_outside_pressure"
state_topic: "outside/pressure"
device_class: atmospheric_pressure
unit_of_measurement: 'hPa'
# WIND SPEED
- name: "Wind speed"
unique_id: "pyramidak_outside_wind"
state_topic: "outside/logic/analog"
device_class: wind_speed
unit_of_measurement: 'km/h'
# RAINDROPS
- name: "Raindrops"
unique_id: "pyramidak_outside_raindrops"
state_topic: "outside/logic/digital"
# or
state_topic: "outside/logic/analog"
# HOME ASSISTANT SENSORS LAYOUT
type: grid
title: Living room
cards:
- type: gauge
entity: sensor.home_temperature
min: 19
severity:
green: 22
yellow: 25
red: 28
name: Temperature
unit: ' '
needle: true
max: 31
- type: gauge
entity: sensor.home_humidity
min: 20
max: 100
severity:
green: 40
yellow: 60
red: 80
name: Humidity
needle: true
- type: gauge
entity: sensor.home_pressure
min: 985
max: 1040
severity:
green: 1003
yellow: 1023
red: 0
unit: ' '
needle: true
name: Pressure
- type: gauge
entity: sensor.home_co2
min: 0
severity:
green: 0
yellow: 1000
red: 2000
max: 3000
name: Carbon dioxide
unit: ' '
needle: true
- type: gauge
entity: sensor.home_tvoc
min: 0
severity:
green: 0
yellow: 100
red: 200
name: Volatile compounds
unit: ' '
needle: true
max: 300
- type: gauge
min: 1
max: 4
entity: sensor.home_air_score
name: Air quality
severity:
green: 1
yellow: 2
red: 3
needle: true
# PARTICULATE MATTER mass concentration
- name: "Outside PM1.0 mass"
unique_id: "pyramidak_outside_mass_pm1"
state_topic: "outside/particles/mass"
value_template: "{{ value_json.PM1 }}"
device_class: pm1
unit_of_measurement: 'µg/m³'
- name: "Outside PM2.5 mass"
unique_id: "pyramidak_outside_mass_pm25"
state_topic: "outside/particles/mass"
value_template: "{{ value_json.PM25 }}"
device_class: pm25
unit_of_measurement: 'µg/m³'
- name: "Outside PM4.0 mass"
unique_id: "pyramidak_outside_mass_pm4"
state_topic: "outside/particles/mass"
value_template: "{{ value_json.PM4 }}"
device_class: pm10
unit_of_measurement: 'µg/m³'
- name: "Outside PM10 mass"
unique_id: "pyramidak_outside_mass_pm10"
state_topic: "outside/particles/mass"
value_template: "{{ value_json.PM10 }}"
device_class: pm10
unit_of_measurement: 'µg/m³'
# PARTICULATE MATTER number concentration
- name: "Outside PM1.0 number"
unique_id: "pyramidak_outside_number_pm1"
state_topic: "outside/particles/number"
value_template: "{{ value_json.PM1 }}"
device_class: pm1
unit_of_measurement: '#/cm³'
- name: "Outside PM2.5 number"
unique_id: "pyramidak_outside_number_pm25"
state_topic: "outside/particles/number"
value_template: "{{ value_json.PM25 }}"
device_class: pm25
unit_of_measurement: '#/cm³'
- name: "Outside PM4.0 number"
unique_id: "pyramidak_outside_number_pm4"
state_topic: "outside/particles/number"
value_template: "{{ value_json.PM4 }}"
device_class: pm10
unit_of_measurement: '#/cm³'
- name: "Outside PM10 number"
unique_id: "pyramidak_outside_number_pm10"
state_topic: "outside/particles/number"
value_template: "{{ value_json.PM10 }}"
device_class: pm10
unit_of_measurement: '#/cm³'
# HOME ASSISTANT PARTICULATE MATTER LAYOUT
type: grid
title: Dust particles outside
cards:
- type: gauge
entity: sensor.outside_pm2_5_mass
min: 0
max: 125
severity:
green: 0
yellow: 30
red: 70
needle: false
name: PM2.5 µg/m³
unit: ' '
- type: gauge
entity: sensor.outside_pm4_0_mass
min: 0
max: 150
severity:
green: 0
yellow: 40
red: 85
unit: ' '
needle: false
name: PM4 µg/m³
- type: gauge
entity: sensor.outside_pm10_mass
min: 0
max: 175
unit: ' '
severity:
green: 0
yellow: 50
red: 100
name: PM10 µg/m³
- type: gauge
entity: sensor.outside_pm2_5_number
min: 0
severity:
green: 0
yellow: 5
red: 15
max: 25
needle: false
name: 'PM2.5 #/cm³'
unit: ' '
- type: gauge
entity: sensor.outside_pm4_number
min: 0
severity:
green: 0
yellow: 5
red: 15
max: 25
needle: false
name: 'PM4 #/cm³'
unit: ' '
- type: gauge
entity: sensor.outside_pm10_number
name: 'PM10 #/cm³'
unit: ' '
severity:
green: 0
yellow: 5
red: 15
min: 0
max: 25
Automation
Automation and scripts for the central system Home Assistant. You can derive the logic for another system.
System StartStates ReloadDevices ReloadMass UpdateSun State
alias: HA_start
description: ""
trigger:
- platform: homeassistant
event: start
condition: []
action:
- service: script.pyramidak_reload
data: {}
mode: single
alias: pyramidak_reload
sequence:
- service: mqtt.publish
data:
qos: 0
retain: false
topic: pyramidak/brightness/command
- service: mqtt.publish
data:
qos: 0
retain: false
topic: pyramidak/switch/command
- service: mqtt.publish
data:
qos: 0
retain: false
topic: pyramidak/sensor/command
mode: single
icon: mdi:reload
alias: MQTT_reload
sequence:
- service: mqtt.reload
data: {}
- service: script.pyramidak_reload
data: {}
mode: single
icon: mdi:reload-alert
alias: pyramidak_update
sequence:
- service: mqtt.publish
data:
qos: 0
retain: false
topic: pyramidak/update/command
mode: single
icon: mdi:auto-download
alias: sun_state
description: ""
trigger:
- platform: mqtt
topic: pyramidak/sun/command
- platform: state
entity_id:
- sun.sun
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
sequence:
- service: mqtt.publish
data:
topic: pyramidak/sun/state
payload: above_horizon
qos: 0
retain: false
default:
- service: mqtt.publish
data:
topic: pyramidak/sun/state
payload: below_horizon
qos: 0
retain: false
mode: single