Giter VIP home page Giter VIP logo

hass's Introduction

Home Assistant, Tasmota, AppDaemon, Custom Components

Everything has a beginning this is the beginning of the beginning of this page

Software Components

  1. Home Assistant controler

  2. Tasmota - ESP82xx

  3. AppDaemon

  4. InfluxDB/MySQL

  5. Grafana

  6. BlueIris

  7. TasmotaAdmin - for OTA multi devices

  8. Yolo3 plugin for BlueIris — object detection reduce false alarm to zero even in night

  9. dnsmasq

  10. dnscrypt-proxy

  11. tinyproxy

  12. openvpn server/phone client for remote connectivity

Hardware Components

  1. Intel z83

  2. Almost any Tasmota hardware

  3. Xiaomi mii sesnors

Main components

  1. Home water consumption/leakage detection. see wiki

  2. Air Conditioner automation (Electra /Israel)

    • Uses SonOff 4ch pro for cold switch on/off

  3. Alarm: Converting old PIMA Alarm + xiaomi mii sensros to be new smart alarm inspired by konnected

    • Tasmota/Wemo d1/i2c 16 gpio

    • Could scale with gpio/cheaper

    • It uses Tasmota firmware

  4. Media automation

  5. Israel Boiler — keep the water always hot in specific temperature. see wiki

    • Tasmota +Sonoff TH16 + DS18b20 raw chip inside the mechanical termostat of the Boiler

  6. Light — turn them automaticly using PIR

    • Tasmota + WemoD1 mini

  7. Cameras — BlueIris as DVR + PIR using Object detection Yolo3

  8. Weather based Irrigation see wiki

    • Tasmota +Sonoff 4CH Pro

    • 48vAC Power

    • Taps to control the taps

Home Assistant - custom components

Used for defining Tasmota sensors/switch/binary sensors

Sync to version

  1. Home Assistant: 0.103.3

  2. AppDaemon: 3.0.3

How to install custom components into your setup

Copy this project <config directory>/custom_components/ folder to your <config directory> directory make sure you are in sync with the the right version of hass (see above)

tasmota_counter (for Pulse counter/Water)

Using this, you could define a sensor that saves Tasmota counter_id pulses info to none-volatile home assistance database. See discussion here 4681

  - platform: tasmota
    name: water_total
    stopic: water_out
    id: 1
    max_valid_diff: 2000
    unit_of_measurement: 'l'
    icon: mdi:water-pump
    expire_after: 300
    value_template: "{{ (45497 + (value))|int }}"

stopic: the short topic. for example the full topic will be tele/stopic/SENSOR

counter_id: the id of the counter 1..4

max_valid_diff: maximum difference in 60 sec

mqtt_tasmota (Switch)

Define a switch in a simpler way. It just works

  • Always in sync with hass

  • No need Option59,

  • No need startup script command

  • No need to define LWT/Qos. Qos is 1

See discussion here 18703

  switch:
    - platform: tasmota
      name: HASS_DEVICE
      index: '1'
      stopic: SHORT_TOPIC

stopic: the short topic. for example the full topic will be tele/stopic/SENSOR e.g. tele/irrigation/SENSOR

name: e.g. wbi_p1 the switch.wbi_p1 the full name

tasmota_alarm MCP230xx

Define 16/8 binary sensors based on MCP230xx chipset in a simple way. This chip has two mqtt async responses(interrupt and status) and it is tedious to define all of them.

 tasmota:
   devices:
    - name: HASS_NAME
      stopic: TOPIC
      binary_sensors:
         - name: door
           polar: true
         - name: vol
           polar: true
         - name: kitchen
           polar: true
         - name: backdoor
           polar: true

accumulator

Aggregate /accumulate using events the time something is working (e.g. time TV is on) per day/week/month. No need to query the database which is a slow operation

 sensor:
   - platform: accumulator
     name: boiler_total_hours2
     entity_id: switch.b0
     state_on: 'on'
     state_off: 'off'

Support older firmware versions (my home versions) of devices and support more than 8 connected clients to each devices (bug in hass). Have a way to disable the C7 as there is only one that can be connected

dnsmasq tracker

Using script to trigger tracker from tracking-dhcp use custom component to let hass known mqtt_dnsmasq.py to get the info from dnsmasq.sh

Irrigation based on Weather actual data

The objective is to irrigate base on actual weather data (no forcast). A simple model of leaky bucket from networking (policer) is used.

  1. Rain will fill the bucket (up to maximum)

  2. Evaporation reduce the bucket - there are many models for ev

The simplet Blaney-Criddle is used here (base on mean temperature and p - hours of daylight )

  1. Irrigation time is based on the bucket level at the time of irrigation time.

Irrigation time = (-bucket level) * max_tap_time (min)

After Irrigation the bucket is zeroed WBI works the same as your old system it just reduce the time when it it fits (e.g. rain, cold days etc)

Example:

Table 1. Without wbi
Day old value evaporation (-) rain Ev (+) new value desc

0

0

-200

+500

+300

rain of ~5mm total

1

+300

-200

0

+100

no rain , no irrigation

2

+100

-200

0

-100

can irrigate

3

-100

-200

0

-300

can irrigate

4*

-300

-100

0

0

can irrigate — scheduled calculate the time

Table 2. Without wbi
Day old value evaporation (-) rain Ev (+) new value desc

0

0

-300

0

-300

rain of ~5mm total

1

-300

-300

0

-600

no rain , no irrigation

2

-600

-300

0

-900

can irrigate

3

-900

-300

0

-1200

can irrigate

4*

-1200

-300

0

0

can irrigate — scheduled calculate the time

As you can see this simple model can tune the irrigation time dynamically base on the weather actual data (again, no forcast needed) The feedback/calculation is slow and done per day

Sample of compoenent
wb_irrigation:
  api_key: !secret openweathermap_key
  rain_factor: 120
  max_ev: 3750
  min_ev: -1500.0
  name: "wb_irrigation"
  longitude: !secret accurate_longitude
  latitude: !secret accurate_latitude
  taps:
    - name: p1
    - name: p2
  1. api_key: a free key to openweathermap.org

  2. rain_factor: ev/mm factor

  3. max_ev: the maximum of the bucket level. if a rainy day has an evaporation of ~150 ev. 3750 means that after a good rain we can stop irrigation for ~20 days

  4. min_ev: the minimum of the bucket level. it is not possible to compensate for more than this ev

  5. longitude,latitude for accurate value for irrigation

  6. taps names. each will have a sensor with bucket calculation

It will define a few sensors with prefix of name_xx for rain/ev/bucket for each tap With the above example there would be wb_irrigation_p1 and wb_irrigation_p2 sensors one for each tap.

For the switch relay (turn on/off the water taps) Sonoff 4ch pro is used. In this example the two first channels are used

Tasmota configuration (once)
Rule1 on Power1#state==1 do  RuleTimer1 1800 endon on Rules#Timer=1 do power1 off endon on Power1#state==0 do  RuleTimer1 off endon
Rule2 on Power2#state==1 do  RuleTimer2 2700 endon on Rules#Timer=2 do power2 off endon on Power2#state==0 do  RuleTimer2 off endon
Rule1 on
Rule2 on
poweronstate 0
TelePeriod 60
SetOption36 20

The first tap is limited to 30min (if it is disconnected for some reason from the controller) and for tap 2 it is 45 min

Appdaemon apps

HeatApp app

A/C Type: Electra with SonOff 4ch for enable/disable, connected to CLK input (plan to reverse engineer modbus signal for better way controling this)

Keep the A/C at specific temperator, at specific days of the week

 heater_ac1:
   module: heat_app
   class: HeatApp
   schedule:
       - { mode: a, start: { t: "17:10:00", d: 6}, end: { t: "17:11:00", d: 6} }
       - { mode: a, start: { t: "17:15:20", d: 6}, end: { t: "23:30:40", d: 6} }
       - { mode: a, start: { t: "08:00:00", d: 7}, end: { t: "13:30:00", d: 7} }
       - { mode: a, start: { t: "15:30:00", d: 7}, end: { t: "19:30:00", d: 7} }

CBoilerAutomation app

 boiler_automation:
   module: heat_app
   class: CBoilerAutomation
   switch: switch.b0
   temp: sensor.btemp0
   input_automation: input_boolean.boiler_auto_enable
   input_temp_min:   input_number.boiler_temp_min
   input_temp_max:   input_number.boiler_temp_max
   sensor_eff_power: variable.boiler_eff_power0
   sensor_eff_solar:  variable.boiler_eff_solar0

Keep the water in the bolier always hot. calculate some efficiency metrics

Input: Temperator of the water inside the bolier Output: Enable/Disable the heater

Tasmota configuration (once)
Rule1 on Power1#state==1 do  RuleTimer1 7200 endon on Rules#Timer=1 do power off endon on Power1#state==0 do  RuleTimer1 off endon
Rule1 on
poweronstate 0
TelePeriod 60
SetOption36 20
  • Rule1 The first rule make sure that if sonoff (TH16) disconnect from controler (wifi/broker is down/hass is down) the power won’t stay on for more than 2 hours

  • poweronstate 0 : if sonoff reset set power to off (rules won’t help here, beacuse rules trigger by change and not at boot)

  • SetOption36 20 : to disable boot loop

  • TelePeriod 60 : set notification each 1 min

CWaterMonitor app

see wiki for a full example

Monitor the water consumption, notify in case of irregularity like leakage, high bursts, not at home etc

Water meter: pulse every 1 liter, ev output iot: wemo d1,tasmota, counter

water_monitor:
  module: heat_app
  class: CWaterMonitor
  sensor_water_total: sensor.water_total
  sensor_water_leak_detector: variable.water_leak_detector
  sensor_water_bursts: variable.water_bursts
  watchdog_duration_min: 50
  watchdog_leakage_ticks: 3
  max_day: 2000
  max_burst: 400

SimpleTimerOff

Turn off a switch after timeout of x min

OutdoorLampWithPir app

Turn on light based by PIR sensor

Weather base irrigation

see wiki for a full example

The app is responsible to to turn on the taps in specific schedule.
The total time is calculated from the weather component (wb_irrigation see below).
In case the tap state is changed to ON (manually) the time is taken from the input and weather queue is not updated.+ It is possible to estimate how much littler is consumed by each tap using the global water input sensor (if exists)

See here for switch and sensor defenition for this app to work pkgs/irrigation.yaml.+ The app is located here CWBIrrigation.+

Irrigation configuration
# irrigation app
wb_irrigation:
  module: heat_app
  class: CWBIrrigation
  m_temp_celsius: 26 #fill from here https://www.holiday-weather.com/[your location]/averages/
  m_temp_hours: 12 #fill from here https://www.holiday-weather.com/[your location]/averages/
  enabled: input_boolean.wbi_enabled #disable irrigation  # disable the irrigation
  water_sensor: sensor.water_total_external_norm # read total water  # optional to read water global sensor in litters
  taps:
     - name: p1  # the name of the tap
       days: [1,3,5]  # 1-7 1 for sunday, .. 7 for saturday
       stime: "05:45:00" # time to start irrigating
       m_week_duration_min: 60 # weakly total time in minutes at the hottest season
       switch: switch.wbi_p1 # the switch for on/off - on the tap is open, off - close
       manual_duration: input_number.wbi_p1_duration # the time in minuts for manual on/off
       queue_sensor: sensor.wb_irrigation_p1   # the calculated queue/bucket sensor from wb_irrigation sensors
       water_sensor: variable.wbi_water_p1 # calculated from input water_sensor tht total for this tap

     - name: p2
       days: [2,5]
       stime: "05:00:00"
       m_week_duration_min: 20
       switch: switch.wbi_p2
       manual_duration: input_number.wbi_p2_duration
       queue_sensor: sensor.wb_irrigation_p2
       water_sensor: variable.wbi_water_p2

hass's People

Contributors

hhaim avatar theunreal avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.