Skip to content

Instantly share code, notes, and snippets.

@jaimemrjm
Last active November 10, 2023 22:16
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jaimemrjm/325880506ec3e4e566a632906fbb26bb to your computer and use it in GitHub Desktop.
Save jaimemrjm/325880506ec3e4e566a632906fbb26bb to your computer and use it in GitHub Desktop.
Good ideas I have found to implement or configure in Home Assistant

Clean

Clean entities by using “Services” and select “Purge Entities”: https://community.home-assistant.io/t/how-to-remove-unwanted-entities/433103/10?u=el-salmon

Notifications

Notify when sensor is above some value:

Weather

Lights

Switches

Rolling shutter blinds

Broadlink (IR codes)

Software Sensors

Location

Disk usage notification

Alexa media-player and Text-to-speech (TTS)

Hardware sensors

Washing machine

UX and Lovelace

Hack firmware

Under Linux

2-steps authentication

Integration

MQTT and Home Assistant

Integration with Xiaomi Vacuum

Integration with hardware

Integration with Amazon Alexa

Integration with Amazon Fire TV and Android TV.

Integration with Samsung TVs

Integration with Telegram

Web Access

Integration with Midas Connect (Xee)

Integration with Yi Cameras

Integration with Pi-Hole

Integration with Tuya devices

The old library is being replaced with the new one:

Backup

Public HA configurations

Coding

Datetime in template:

- data_template:
      message: >-
        {{ now().strftime("%Y%m%d-%H%M%S") }}

Low battery sensor

- platform: template
  sensors:
    baterias_bajas:
      friendly_name: Bateria Baja
      icon_template: '{% if states.sensor.baterias_bajas.state %}mdi:alert{% else %}mdi:approval{% endif %}'
      value_template: >-
        {%- for state in states if state.attributes.battery_level or state.attributes.battery -%} #(1)Para utilizar cuando el nivel de bateria esta como atributo
          {%- set battery = state.attributes.battery_level or state.attributes.battery -%} #(2)Nivel de bateria como atributo
          {%- if battery == 'High' -%}
            {%- set battery = 100 -%}
          {%- endif -%}
          {%- if battery | int < 15 -%}
            - {{state.attributes.friendly_name}} --> {{ state.attributes.battery_level or state.attributes.battery }} % #(3)Muestra el nombre y el nivel de bateria

          {%- endif -%}
        {%- endfor -%}

## Ejemplos de posibles variaciones:
#(1)        {%- for state in states if ('battery' in state.attributes.device_class and state.domain in ['sensor']) -%} ##Solo indicaria si es un sensor y tiene clase battery
#(1)        {%- for state in states if ('battery' in state.attributes.device_class) -%} ##Indicaria cualquier entity con clase battery
#(2)          {%- set battery = state.state -%}  ##Cuando el nivel de bateria es el propio estado como cuando se crean sensores para ello
#(3)            - {{state.attributes.friendly_name}} --> {{ state.state }} % ##Utilizar con device_class

Cover with real-time status bar

cover:
 - platform: mqtt
name: "Persiana"
availability_topic: "psm/marcos/persiana/LWT"
payload_available: "Online"
payload_not_available: "Offline"
position_topic: "psm/marcos/persiana/RESULT"
value_template: >
 {% if ('Shutter1' in value_json) and ('Position' in value_json.Shutter1) %}
 {{ value_json.Shutter1.Position }}
 {% else %}
 {% if is_state('cover.persiana_marcos', 'unknown') %}
 50
 {% else %}
 {{ state_attr('cover.persiana_marcos','current_position') }}
 {% endif %}
 {% endif %} 
position_open: 100
position_closed: 0
set_position_topic: "psm/marcos/persiana/cmnd/ShutterPosition1"
command_topic: "psm/marcos/persiana/cmnd/Backlog"
payload_open: "ShutterOpen1"
payload_close: "ShutterClose1"
payload_stop: "ShutterStop1"
retain: false
optimistic: false
qos: 1

Another ideas for Domotic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment