The .table-striped class adds zebra-stripes to a table:
| Sensors Name | Entity (Filter-by) | Attributes |
|---|---|---|
| Aqara Thermostat (Temps) | Aqa.Thermo | device_class: temperature |
| Tado Smart Radiator (Temps) | tado Smart Radiator | device_class: temperature |
| Tapo Thermo Sensors (x5) | Tapo | device_class: temperature |
| Gets all Tado Rads | None | offset_celsius |
| All My Tapo Plugs (NOT Plug-02) | switch.tapo_plug | friendly_name: Tapo:Plug |
| Tapo Plug-02 (ONLY!) | switch.tapo_plug | friendly_name: Tapo: Plug -- * Notice the gap!! * |
| All My Tapo Plugs (Current Watts) | tapo_plug | device_class: power |
| Code Purpose | Label | YAML Code |
|---|---|---|
| Gets the current Date, formatted my way | Date = Sun 25-01-2026 | {{ now().timestamp() | timestamp_custom('%a %d-%m-%Y') }} |
| Gets the current Time, formatted my way | Time = 7:29 PM | {{ now().timestamp() | timestamp_custom('%-I:%M %p') }} |
| Tapo Thermo Sensors (x5) | Tapo | device_class: temperature |
| Sensors_Name__HERE | Entity_Filter__HERE | Attribute_Filter__HERE |
Some of my OG Test Code
Syntax highlighting |
Highlight JS
Scroll down to... As HTML Tags
Available Styles: | GitHub: Available Styles
Supported Languages: | GitHub: Supported Languages
How to Add Syntax Highlighting to Code on Your Website: | YT Video
{## Imitate available variables: ##}
{% set my_test_json = {
"temperature": 25,
"unit": "°C"
} %}
The temperature is {{ my_test_json.temperature }} {{ my_test_json.unit }}.
{# My Test: {{ states("climate.my_office") }} #}
{% set actual_temp = states('sensor.lumi_lumi_weather_aqara_thermo_1_temperature') | float(0) %}
My Aqa accurate sensor = {{ actual_temp }}
{% set actual_temp_02 = states('sensor.lumi_lumi_weather_aqara_thermo_1_temperature') | round(1) %}
------------------------------------------
My Aqa accurate sensor (Rounded-up) = {{ actual_temp_02 }}
------------------------------------------
{% set tado_temp = state_attr('climate.my_office', 'current_temperature') | float(0) %}
------------------------
My Tado Rad Temp = {{ tado_temp }}
------------------------
{# {% set actual_temp = states('sensor.external_room_temperature') | float(0) %}
{% set tado_temp = state_attr('climate.living_room_radiator', 'current_temperature') | float(0) %}
{% set current_offset = state_attr('climate.living_room_radiator', 'offset_celsius') | float(0) %} #}
---
{% set current_offset = state_attr('climate.my_office', 'offset_celsius') | float(0) %}
Tado current_offset (-1.3) = {{ current_offset }}
---
{% set correct_offset = (actual_temp - tado_temp) | round(1) %}
{# THIS Correct Offset (-1.3) = {{ correct_offset }} #}
---
Calculated Offset v1 (actual-Tado) THIS = {{ (actual_temp - tado_temp) | round(1) }}
Calculated Offset v2 (actual-Tado+OffSet) = {{ ((actual_temp - tado_temp) + current_offset) | round(1) }}
Calculated Offset v2.1 (actual-Tado+OffSet) = {{ ((tado_temp - actual_temp) + current_offset) | round(1) }}
Calculated Offset v3 (Tado-Actual) = {{ (tado_temp - actual_temp) | round(1) }}
Gemini OffSet = {{ ((actual_temp - tado_temp) + current_offset) | round(1) }}
Set Offset To Zero = {{ 0 }}
---
Tado Corrected Temp (THIS) = >>>> {{ (tado_temp + correct_offset) | round(1) }} <<<<
My Aqa accurate Temp = ** {{ actual_temp }} **
Tado Minus Correct Offset = {{ tado_temp - correct_offset| round(1) }}
Tado Corrected Temp = {{ ((actual_temp - tado_temp) + current_offset) | round(1) }}
---
{{ (states('sensor.lumi_lumi_weather_aqara_thermo_1_temperature') | float -
state_attr('climate.my_office', 'current_temperature') | float) | abs > 0.5 }}
---
Tab-A Battery+ Level = {{ state_attr('sensor.sam_tab_a_battery_plus', 'battery_last_reported_level') }} %
Tab-A Charging MODE = {{ states('input_select.samsung_tab_a_battery_charging_mode') }}
---
Tab-A Upper = {{ states('input_select.sam_tab_a_re_charge_level_limiter') }}
Tab-A Lower = {{ states('input_select.sam_tab_a_low_battery_level_limiter') }}
---
Tab-A Battery = {{ states('sensor.sam_tab_a_battery_plus') }}
iPad Mini Battery = {{ states('sensor.maxs_ipad_mini_old_v2_2024_battery_level') }}
---
Tapo Plug-15 = {{ states('sensor.tapo_plug_15_current_consumption') }}
Tapo Plug-15 = {{ states('switch.tapo_plug_15') }}
---
Date = {{ now().timestamp() | timestamp_custom('%a %d-%m-%Y') }}
Time = {{ now().timestamp() | timestamp_custom('%-I:%M %p') }}
p.exists() # True/False
p.is_file() # True if file
p.is_dir() # True if directory
p.is_symlink() # True if symlink
# Read / write text
p.write_text("Hello World")
content = p.read_text()
# Read / write bytes
p.write_bytes(b"binary data")
data = p.read_bytes()
# Make directories
Path("new/folder").mkdir(parents=True, exist_ok=True)
# Remove file
p.unlink()
# Rename / move
p.rename("new_name.txt")
p.replace("some/other/location.txt")
# Match all .txt files
for file in Path("docs").glob("*.txt"):
print(file)
# Recursive glob
for file in Path("docs").rglob("*.txt"):
print(file)
p = Path("docs/../report.pdf")
p.resolve() # Absolute normalized path
The iterdir() method allows you to iterate over all the files and subdirectories in a folder.
It is particularly useful for processing all files in a directory or performing operations on each
entry.
Since iterdir() returns an iterator,
entries are retrieved on-demand as you go through the loop.
# My Default way for Python to find the current App folder
APP_DIR:Path[str] = Path(__file__).resolve().parent
p = Path("docs")
# Basic Iteration & Print Results
for item in p.iterdir():
print(item)
# Filter files only
for f in Path(".").iterdir():
if f.is_file():
print(f)
# Filter directories only
for d in Path(".").iterdir():
if d.is_dir():
print(d)
# Sorted
for entry in sorted(Path(".").iterdir()):
print(entry.name)
# Filter by extension
for f in Path(".").iterdir():
if f.suffix == ".txt":
print(f)
# List comprehension
files = [f.name for f in Path(".").iterdir() if f.is_file()]
| Method | Scope | Example |
|---|---|---|
iterdir() |
Direct children only | Path(".").iterdir() |
glob("*.py") |
Pattern-matching, 1 level deep | Path(".").glob("*.py") |
rglob("*.py") |
Recursive search | Path(".").rglob("*.py") |
| Method | Arguments | Default | Explanation |
|---|---|---|---|
mkdir() |
mode, parents, exist_ok | 0o777, False, False | Create a directory. parents=True creates parent directories. exist_ok=True ignores if directory exists. |
rmdir() |
- | - | Remove empty directory. Raises OSError if not empty. |
unlink() |
missing_ok | False | Delete a file. missing_ok=True ignores if file missing. |
rename() |
target | - | Rename or move file. Overwrites not allowed if exists. |
replace() |
target | - | Rename or move file. Overwrites if target exists. |
touch() |
mode, exist_ok | 0o666, True | Create empty file. exist_ok=True ignores if file exists. |
open() |
mode, encoding | "r", None | Open file handle like open(). |
read_text() |
encoding, errors | None, None | Read file as string. |
write_text() |
data, encoding, errors | - | Write string to file. |
glob() |
pattern | - | Pattern match files in directory. |
rglob() |
pattern | - | Recursive pattern match files. |
iterdir() |
- | - | Iterate over directory entries (direct children only). |