############# MQTT ################
#------------------ rpi-bram ---------------------#
sensor:
- name: rpibram_temp
  state_topic: bram/arbeit/bme680/
  value_template: '{{value_json.temperature | round(1) }}'
  unit_of_measurement: '°C'

- name: rpibram_humidity
  state_topic: bram/arbeit/bme680/
  value_template: '{{value_json.humidity | round(1) }}'
  unit_of_measurement: '%'
  
- name: rpibram_pressure
  state_topic: bram/arbeit/bme680/
  value_template: '{{value_json.pressure | round(1) }}'
  unit_of_measurement: 'mBar'
  
- name: rpibram_airquality
  state_topic: bram/arbeit/bme680/
  value_template: '{{value_json.air_quality | round(1) }}'
  unit_of_measurement: '%'

#----------- RPi Amlab -----------#
- name: "rpiamlab_datetime"
  state_topic: "bram/garten/rpi-amlab/date"
  unit_of_measurement: ""

- name: "rpiamlab_diskfree"
  state_topic: "bram/garten/rpi-amlab/diskfree"
  unit_of_measurement: "Gb"
  value_template: '{{ value | multiply(0.000001) | round(2) }}'

- name: "rpiamlab_diskusedpercent"
  state_topic: "bram/garten/rpi-amlab/diskusedpercent"
  unit_of_measurement: "%"

- name: "rpiamlab_load5min"
  state_topic: "bram/garten/rpi-amlab/load5min"
  unit_of_measurement: ""

- name: "rpiamlab_cputemp"
  state_topic: "bram/garten/rpi-amlab/cputemp"
  unit_of_measurement: "°C"

- name: "rpiamlab_memtotal"
  state_topic: "bram/garten/rpi-amlab/memtotal"
  unit_of_measurement: "Mb"
  value_template: '{{ value | multiply(0.001) | round(2) }}'

- name: "rpiamlab_memused"
  state_topic: "bram/garten/rpi-amlab/memused"
  unit_of_measurement: "Mb"
  value_template: '{{ value | multiply(0.001) | round(2) }}'

- name: "rpiamlab_memfree"
  state_topic: "bram/garten/rpi-amlab/memfree"
  unit_of_measurement: "Mb"
  value_template: '{{ value | multiply(0.001) | round(2) }}'

- name: "rpiamlab_ipaddr"
  state_topic: "bram/garten/rpi-amlab/ipaddr"
  unit_of_measurement: ""

- name: "rpiamlab_rssi"
  state_topic: "bram/garten/rpi-amlab/rssi"
  unit_of_measurement: "dBm"

#----------- RPi Cam -----------#

- name: "Lufttemperatur garten"
  state_topic: "bram/garten/rpi-cam/dht22-temperature"
  unit_of_measurement: "°C"
  
- name: "Luftfeuchtigkeit garten"
  state_topic: "bram/garten/rpi-cam/dht22-humidity"
  unit_of_measurement: "%"

- name: "rpicam_datetime"
  state_topic: "bram/garten/rpi-cam/date"
  unit_of_measurement: ""

- name: "rpicam_diskfree"
  state_topic: "bram/garten/rpi-cam/diskfree"
  unit_of_measurement: "Gb"
  value_template: '{{ value | multiply(0.000001) | round(2) }}'

- name: "rpicam_diskusedpercent"
  state_topic: "bram/garten/rpi-cam/diskusedpercent"
  unit_of_measurement: "%"

- name: "rpicam_load5min"
  state_topic: "bram/garten/rpi-cam/load5min"
  unit_of_measurement: ""

- name: "rpicam_cputemp"
  state_topic: "bram/garten/rpi-cam/cputemp"
  unit_of_measurement: "°C"

- name: "rpicam_memtotal"
  state_topic: "bram/garten/rpi-cam/memtotal"
  unit_of_measurement: "Mb"
  value_template: '{{ value | multiply(0.001) | round(2) }}'

- name: "rpicam_memused"
  state_topic: "bram/garten/rpi-cam/memused"
  unit_of_measurement: "Mb"
  value_template: '{{ value | multiply(0.001) | round(2) }}'

- name: "rpicam_memfree"
  state_topic: "bram/garten/rpi-cam/memfree"
  unit_of_measurement: "Mb"
  value_template: '{{ value | multiply(0.001) | round(2) }}'

- name: "rpicam_ipaddr"
  state_topic: "bram/garten/rpi-cam/ipaddr"
  unit_of_measurement: ""

- name: "rpicam_rssi"
  state_topic: "bram/garten/rpi-cam/rssi"
  unit_of_measurement: "dBm"

#----------------- rpi-wg ------------------------#

- name: rpi_wg_boottime
  state_topic: "bram/wg/sysinfo"
  value_template: '{{ value_json.boottime }}'

- name: rpi_wg_time
  state_topic: "bram/wg/sysinfo"
  value_template: '{{ value_json.currenttime }}'
  
- name: rpi_wg_cputemp
  state_topic: "bram/wg/sysinfo"
  value_template: '{{ value_json.cputemp }}'
  unit_of_measurement: "°C"

- name: rpi_wg_cpuusage
  state_topic: "bram/wg/sysinfo"
  value_template: '{{ value_json.cpuusage }}'
  unit_of_measurement: "%"
  
- name: rpi_wg_diskfree
  state_topic: "bram/wg/sysinfo"
  unit_of_measurement: "Gb"
  value_template: '{{ value_json.ssdfree | multiply(0.000000001) | round(2) }}'

- name: rpi_wg_diskused
  state_topic: "bram/wg/sysinfo"
  value_template: "{{value_json.ssdusage }}"
  unit_of_measurement: "%"

- name: rpi_wg_load1min
  state_topic: "bram/wg/sysinfo"
  value_template: "{{ value_json.load1min }}"

- name: rpi_wg_load5min
  state_topic: "bram/wg/sysinfo"
  value_template: "{{ value_json.load5min }}"

- name: rpi_wg_load15min
  state_topic: "bram/wg/sysinfo"
  value_template: "{{ value_json.load15min }}"

- name: rpi_wg_memavail
  state_topic: "bram/wg/sysinfo"
  unit_of_measurement: "Gb"
  value_template: '{{ value_json.memavail | multiply(0.000000001) | round(1) }}'  

- name: rpi_wg_memused
  state_topic: "bram/wg/sysinfo"
  unit_of_measurement: "%"
  value_template: '{{ value_json.memused }}'
  
- name: rpi_wg_rssi
  state_topic: "bram/wg/sysinfo"
  unit_of_measurement: "dBm"
  value_template: '{{ value_json.rssi }}'
  
#----------- wg bme680 -----------#
- name: "wg_temperature"
  state_topic: "bram/wg/bme680-temperature"
  unit_of_measurement: "°C"

- name: "wg_humidity"
  state_topic: "bram/wg/bme680-humidity"
  unit_of_measurement: "%"

- name: "wg_pressure"
  state_topic: "bram/wg/bme680-pressure"
  unit_of_measurement: "hPa"

- name: "wg_air_quality"
  state_topic: "bram/wg/bme680-air_qual"
  unit_of_measurement: "%"

#----------- Tanks -----------#
- name: "tank2"
  state_topic: "bram/garten/tank2/level"
  unit_of_measurement: "cm"
  qos: 0

- name: "tank1"
  state_topic: "bram/garten/tank1/level"
  unit_of_measurement: "cm"
  qos: 0

#-------- pyCom GH ---------#
- name: "GH_zeit"
  state_topic: "bram/gh/time"
  unit_of_measurement: "h"
  qos: 0

- name: "GH_TemperatureMP"
  state_topic: "bram/gh/t_mp"
  unit_of_measurement: "°C"
  qos: 0

- name: "GH_TemperatureSI"
  state_topic: "bram/gh/t_si"
  unit_of_measurement: "°C"
  qos: 0

- name: "GH_humidity"
  state_topic: "bram/gh/rH"
  unit_of_measurement: "%"
  qos: 0

- name: "GH_pressure"
  state_topic: "bram/gh/hPa"
  unit_of_measurement: "hPa"
  qos: 0

- name: "GH_light"
  state_topic: "bram/gh/lux"
  unit_of_measurement: "lux"
  qos: 0
 
- name: "GH_volt"
  state_topic: "bram/gh/volt"
  unit_of_measurement: "V"
  qos: 0

- name: "GH_WLAN_signal"
  state_topic: "bram/gh/rssi"
  unit_of_measurement: "rssi"
  qos: 0
  
  
##### SWITCHES #####
switch:
- name: "swpump1"
  state_topic: "bram/garten/tank1/pump"
  command_topic: "bram/garten/tank1/pump/set"
  payload_on: "on"
  payload_off: "off"
  optimistic: false
  qos: 0
  retain: false
  
- name: "swpump2"
  state_topic: "bram/garten/tank2/pump"
  command_topic: "bram/garten/tank2/pump/set"
  payload_on: "on"
  payload_off: "off"
  optimistic: false
  qos: 0
  retain: false
  
- name: "GH_light_switch"
  state_topic: "bram/gh/DO"
  command_topic: "bram/gh/DO"
  payload_on: "P4,1"
  payload_off: "P4,0"
  optimistic: false
  qos: 0
  retain: true
  
- name: "GH_P8_switch"
  state_topic: "bram/gh/DO"
  command_topic: "bram/gh/DO"
  payload_on: "P8,1"
  payload_off: "P8,0"
  optimistic: false
  qos: 0
  retain: true
  
- name: "GH_P10_switch"
  state_topic: "bram/gh/DO"
  command_topic: "bram/gh/DO"
  payload_on: "P10,1"
  payload_off: "P10,0"
  optimistic: false
  qos: 0
  retain: true
  
- name: "GH_P11_switch"
  state_topic: "bram/gh/DO"
  command_topic: "bram/gh/DO"
  payload_on: "P11,1"
  payload_off: "P11,0"
  optimistic: false
  qos: 0
  retain: true
  
##### BINARY SENSORS #####  

# Dachfenster state
binary_sensor:
- name: "WG Dachfenster"
  state_topic: "bram/wg/WindowsAreOpen"
  payload_on: "true"
  payload_off: "false"
