@bind_hass
def attach(hass: HomeAssistant, obj: Any) -> None:
    'Recursively attach hass to all template instances in list and dict.'
    if isinstance(obj, list):
        for child in obj:
            attach(hass, child)
    elif isinstance(obj, collections.abc.Mapping):
        for (child_key, child_value) in obj.items():
            attach(hass, child_key)
            attach(hass, child_value)
    elif isinstance(obj, Template):
        obj.hass = hass
Recursively attach hass to all template instances in list and dict.
@bind_hass
def attach(hass: HomeAssistant, obj: Any) -> None:
    
    if isinstance(obj, list):
        for child in obj:
            attach(hass, child)
    elif isinstance(obj, collections.abc.Mapping):
        for (child_key, child_value) in obj.items():
            attach(hass, child_key)
            attach(hass, child_value)
    elif isinstance(obj, Template):
        obj.hass = hass