infra/roles/hass-core
ben cb2122bf55
ben/infra/pipeline/head This commit looks good Details
Recent changes: 2023-12 (!12)
hass-core: gitea

users: ansible tag for updating authorized_keys

www: canonical urls and gitea robots

haproxy: redirect http://sudo.is

www: canonical header for index.html pags in /docs

www: redirects

saned: link from 2022

www: firefox page changed url

401, 403 pages, split server names, redirect alt domains

gitea; redirect bing found was needed

hass-esphome: disable active bleproxy

hass-core: last_cleaned

www: canonical only on 200

statidc sitemap

www: canonical header for an url google found

ansible: removed qutoes from ansible_managed

coturn: updated and cleaded up

edge: added role coturn to edge systype

matrix-synapse: coturn

hass-core: prevent esphome 'binary_sensors.occupancy_' from triggering while away

gitea: agressively clean 'data/gitea/repo-archive'

hass-core: adding attributes for study outlets

hass-esphome: bend argparse

hass-esphome: show subs

www: prepare redirects

chantge preppped redirect

hass-core: fix typo

hass-core: potato

gitea: enable push to create

link to debian wiki page

hass-appdaemon: fix dir owneship for redis

mainframe: convergence, small initial fixes

mainframe: move convergence scripts

mainframe: fix permissions on convergence scripts

mainframe: convergence argument parsing

hass-core: two simple long-time ideas written down

hass-core: more potato

hass-core: noop placeholder fan in placeholder groups to keep entity_ids

hass-core: templated switch

hass-core: renamed sensor

mainframe: prep more redirects

hass: link hass-deconz role

hass: move appdaemon

hass: fix links to docs site

pihole: adlists but they are not managed in files anymore

airconnect: fix handler tasks

ansible: json indent

hass-core: cleanup of README

hass-core: make sensor return last value when charging and the attribute is '0'

hass-core: add attribute with source value

Reviewed-on: b/infra#12
Co-authored-by: Ben Kristinsson <ben@sudo.is>
Co-committed-by: Ben Kristinsson <ben@sudo.is>
2024-01-04 18:23:37 +00:00
..
defaults Recent changes (!9) 2023-11-23 17:51:18 +00:00
files Recent changes: 2023-12 (!12) 2024-01-04 18:23:37 +00:00
handlers Recent changes: 2023-12 (!12) 2024-01-04 18:23:37 +00:00
meta Recent changes (!9) 2023-11-23 17:51:18 +00:00
tasks Recent changes: 2023-12 (!12) 2024-01-04 18:23:37 +00:00
templates Recent changes: 2023-12 (!12) 2024-01-04 18:23:37 +00:00
README.md Recent changes: 2023-12 (!12) 2024-01-04 18:23:37 +00:00
home-assistant.svg Recent changes (!9) 2023-11-23 17:51:18 +00:00
room_entered_co2.png Recent changes: 2023-12 #2 (!11) 2023-12-17 16:22:57 +00:00
room_entered_voc.png Recent changes: 2023-12 #2 (!11) 2023-12-17 16:22:57 +00:00

README.md

hass

Home Assistant logo

Documentation: www.sudo.is/docs/hass/

Ideas/notes

Trigger-based timestamp sensors for home entry/exit

I think it was binary_sensor.home_exit_3 and binary_sensor.home_entry_3 that were the best-implemented (there are too many, the not-so-well-implemented should be cleaned up)

Since entry/exit is "event-based", we need a timpstamp sensor for last time they were detected. (The binary_sensor ones are also useful)

 - trigger:
    - platform: state
      entity_id: binary_sensor.home_entry_3
      from: "off"
      to: "on"
   sensor:
    - name: home_entry
      device_class: timestamp
      state: |
        {{ now().isoformat() }}        

 - trigger:
    - platform: state
      entity_id: binary_sensor.home_exit_3
      from: "off"
      to: "on"
   sensor:
    - name: home_exit
      device_class: timestamp
      state: |
        {{ now().isoformat() }}        

Then a binary_sensor can be created to show whichh happened last

binary_sensor:
    - name: some_good_name
      state: |
        {{ if states("sensor.home_entry") > states("sensor.home_exit") }}        

Would be true (or "on") if someone entered the house more recently than if someone left

Night-mode from timpstamp sensors

Use other timestamp sensors to create a "night-mode" sensor and switch

binary_sensor:
    - name: night_mode
     state: |
        {{ if states("sensor.a_going_to_bed_event_timestamp") > states("sensor.morning_alarm_next") }}        

Where both sensor.a_going_to_bed_event_timestamp and sensor.morning_alarm_next are sensors with timestamp as device_class.

Mapping room names to valetudo segment id

{% for key, value in states.sensor.valetudo_vacuum_robot_map_segments.attributes.items() -%}
{% if key.isdigit() -%}
{{ value }}: {{ key }}
{% endif -%}
{% endfor -%}

Renders:

Bedroom: 2
# ..
Kitchen: 6

night mode in psuedo code:

set triggers = [yellow_button, alarm_button, done_brushing]
if any(a.last_triggered > alarm_last_run):
    night_mode = true
else:
    night_mode = false

if yellow button/done brushing/orher alarm button was pressed more recently than alarm start/stop, theh set night_mode

weather

possible condition values: https://developers.home-assistant.io/docs/core/entity/weather/#recommended-values-for-state-and-condition

occupancy notes

VOC and CO2 are useful, when occupied:

  • VOC > 0.25-0.30 ppm
  • CO2 > 550-600 ppm

Their derivatives however are supririsngly less useful.

Monitor

Powered on, charging laptop with USB-C: 40-80W Standby (monitor off) charging a laptop: 7-25W Powered on, without charging laptop (laptop connected with hdmi): ~23W (21-24W) Standby, without charging laptop: <2W

Something like this could work?

if timestamp(watts > 45) < timestamp(watts < 3):
  monitor.usb_c_power_state = "charging laptop"
else:
  monitor.usb_c_power_state = "off"

# inverted, not sure which i like better
if timestamp(watts < 3) < timestamp(watts > 45):
  monitor.usb_c_power_state = "off"
else:
  monitor.usb_c_power_state = "off"


if watts > 20:
  if monitor.usb_c_power_state_off:
    monitor.state = True
  else:
    monitor.state = False
else:
  monitor.state = False

Current issues

Unsupported operands

2023-11-06 01:50:41.359 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/prometheus/__init__.py", line 184, in handle_state_changed_event
    self.handle_state(state)
  File "/usr/src/homeassistant/homeassistant/components/prometheus/__init__.py", line 197, in handle_state
    getattr(self, handler)(state)
  File "/usr/src/homeassistant/homeassistant/components/prometheus/__init__.py", line 438, in _handle_light
    value = state.attributes["brightness"] / 255.0
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

Programming in jinja inside of a yaml document... should start on a custom integration + appdaemon.

Resolved issues

Removed custom integrations and cards

  • UI Lovelace Minimalist
  • browser-mod
  • forked-daapd-card
  • button-card
  • iphonedetect
# ls -1 /srv/hass/DISABLED/
browser_mod.storage
forked-daapd-card

UI Lovelace Minimalist

HACS integration: UI Lovelace Minimalist: https://github.com/UI-Lovelace-Minimalist/UI

# ls /srv/hass/config/ui_lovelace_minimalist/
custom_actions  custom_cards  dashboard
# ls /srv/hass/config/custom_components/ui_lovelace_minimalist/
base.py     config_flow.py  __init__.py    __pycache__    __ui_minimalist__
blueprints  const.py        lovelace       services.yaml  utils
cards       enums.py        manifest.json  translations

HACS wouldnt let me remove it ("The UI Lovelace Minimalist integration is configured or ignored, you need to delete the configuration for it before removing it from HACS "),

Integrationn was disabled, removed it from the integration page

Then i could remove it from the HACS integrations.

browser_mod

this file may have been causing issues, removed browser mod a long time ago

# mv /srv/hass/home-assistantconfig/.storage/browser_mod.storage  ../DISABLED/

forked-daapd-card

some ad-hoc one off install

# mv /srv/hass/home-assistant/config/www /srv/hass/DISABLED

dont think it was ever used

see also: ops/meta#52

Mysterious sensor.rest_sensor

homeassistant.exceptions.InvalidStateError: Invalid state with length 9656. State max length is 255 characters.
2023-11-05 16:13:49.067 ERROR (MainThread) [homeassistant.helpers.entity] Failed to set state for sensor.rest_sensor, fall back to unknown

what is sensor.rest_sensor, where is it coming from and how can i remove it?

fixed, see ops/meta#52