# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# autologin if one user
homeassistant:
  auth_providers:
    - type: trusted_networks
      trusted_networks:
        - 127.0.0.1
        - ::1
      allow_bypass_login: true
    - type: homeassistant

  customize:
    sensor.28_012032ca73c6_temperature:
      friendly_name: Outside South
    sensor.28_012032cb2851_temperature:
      friendly_name: Outside North


# Digital Input
binary_sensor:
  - platform: rpi_gpio
    ports:
      17: DI3 Boiler Alert
    invert_logic: false
     
  - platform: rpi_gpio
    ports:
      22: DI2 Free
    invert_logic: true

# Digital Output
switch:
  - platform: rpi_gpio
    invert_logic: true
    ports:
      21: DO1 Boiler
      20: DO2 Outdoor Lights
      26: DO3 Gate Lights
      19: DO4 Water Pump


sensor:
  - platform: command_line
    name: Board Temperature
    command: /bin/cat /sys/devices/virtual/thermal/thermal_zone0/temp
    unit_of_measurement: "°C"
    value_template: '{{ value | multiply(0.001) | round(1) }}'

  - platform: command_line
    name: Board Uptime
    command: /usr/bin/uptime

  - platform: command_line
    name: Board Memory
    command: '/usr/bin/free -h | /usr/bin/awk -F " " ''FNR==2{print "Total: "$2" Used: "$3" Free: "$4}'' '

  - platform: command_line
    name: Water Flow Instant Counter
    command: /bin/cat /tmp/water_flow.instant
    unit_of_measurement: "L/min"
    scan_interval: 10

  - platform: command_line
    name: Water Flow Daily Counter
    command: /bin/cat /tmp/water_flow.daily
    unit_of_measurement: "L"
    scan_interval: 60

  - platform: bme280
    name: Indoor
    i2c_address: 0x76
    operation_mode: 2 
    time_standby: 2
    oversampling_temperature: 2
    oversampling_pressure: 4
    oversampling_humidity: 1
    delta_temperature: -1
    filter_mode: 4
    monitored_conditions:
      - temperature
      - humidity
      - pressure

  - platform: onewire

  - platform: command_line
    name: Water Pressure
    command: /home/homeassistant/spi_mcp3008_wp.sh
    unit_of_measurement: "Bar"
    scan_interval: 30

  - platform: command_line
    name: AC probe 1 current consumption
    command: /home/homeassistant/spi_mcp3008_ac.sh 1
    unit_of_measurement: "W"
    scan_interval: 10

  - platform: command_line
    name: AC probe 2 current consumption
    command: /home/homeassistant/spi_mcp3008_ac.sh 2
    unit_of_measurement: "W"
    scan_interval: 10



climate:
  - platform: generic_thermostat
    name: Main Thermostat
    heater: switch.DO1_Boiler
    target_sensor: sensor.indoor_temperature
    min_temp: 10
    max_temp: 30
    target_temp: 22
    away_temp: 10
    ac_mode: false
    initial_hvac_mode: "heat"





