# Home Assistant

- [Home Assistant](#home-assistant)
  - [Setup and Configuration](#setup-and-configuration)
    - [Schlage Door Lock](#schlage-door-lock)
    - [Philips Hue Lights](#philips-hue-lights)
    - [Shelly](#shelly)
    - [Relative Humidity Calculator](#relative-humidity-calculator)
    - [Font Colors](#font-colors)
    - [Light Indicator for Voice Assistant](#light-indicator-for-voice-assistant)

## Setup and Configuration

### Schlage Door Lock

1. Install Z-wave
2. Install z-wave JS module
3. Add device -> How do you want to add your device -> Legacy Secure
4. Disconnect and Reconnect the battery on the lock
5. Press and hold the zwave button until the light turns solid red, release and it should flash red
   1. (OR) Enter programming pin on lock -> 0 (this may take a few attempts, don't click the pair button)

### Philips Hue Lights

1. I configure all philips hue lights through zigbee directly connected to HA

hue lights support color_temp in mireds, here are some mired-kelvin conversions:

| Kelvin | Mired |
| ------ | ----- |
| 6000   | 167   |
| 4000   | 250   |
| 2600   | 385   |

### Shelly

1. Outbound Websocket `wss://homeassistant.reeseapps.com/api/shelly/ws`

Shelly devices can act as "passive" or "active" bluetooth scanners. Both of these configurations
allow home assistant to proxy bluetooth connections through shelly devices, significantly extending
the range of your home assistant's bluetooth capabilities. Active scanning uses more power but
is quicker to pick up and transmit device information. Note that "gateway mode" is not required,
just enable bluetooth and rpc or select "active" from the configuration menu for the shelly
device.

### Relative Humidity Calculator

<https://www.wikihow.com/Calculate-Humidity>

You can calculate the relative humidity of the outdoor air if warmed to indoor temperatures like so:

```jinja
{% set dew_point = state_attr("weather.forecast_home", "dew_point") %}
{% set air_temp_f = state_attr("climate.ecobee_thermostat", "current_temperature") %}
{% set air_temp = (5/9)*(air_temp_f-32) %}
{% set sat_vap_press = 6.11 * 10**((7.5*air_temp) / (237.3+air_temp)) %}
{% set act_vap_press = 6.11 * 10**((7.5*dew_point) / (237.3+dew_point)) %}
{% set rel_hum = 100*(act_vap_press / sat_vap_press) %}

{{ dew_point }}
{{ air_temp }}
{{ sat_vap_press }}
{{ act_vap_press }}
{{ rel_hum }}
```

### Font Colors

```html
<font color = {{ "green" if state_attr("climate.ecobee_thermostat", "current_humidity") > low_humidity and state_attr("climate.ecobee_thermostat", "current_humidity") < high_humidity else "red" }}>
HVAC Humidity: {{ state_attr("climate.ecobee_thermostat", "current_humidity") }}%
</font>
```

### Light Indicator for Voice Assistant

```yaml
alias: Flash Lights on Bedroom Voice Assistant Start
description: ""
triggers:
  - type: turned_on
    device_id: d50fa1ae499e88bf37225c7e82ed189b
    entity_id: 7ab2896ca3a55efd2e0ee9bba91fdf68
    domain: binary_sensor
    metadata:
      secondary: false
    trigger: device
conditions: []
actions:
  - action: scene.create
    metadata: {}
    data:
      scene_id: bedroombeforescene
      snapshot_entities:
        - light.main_bedroom_lamps
  - action: light.turn_on
    metadata: {}
    data:
      transition: 0.25
      brightness_step_pct: 5
    target:
      entity_id: light.main_bedroom_lamps
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 250
  - action: scene.turn_on
    data:
      entity_id: scene.bedroombeforescene
      transition: 0.25
mode: single
```