def _get_template_state_from_state(hass: HomeAssistant, entity_id: str, state: (State | None)) -> (TemplateState | None):
    if (state is None):
        _collect_state(hass, entity_id)
        return None
    return TemplateState(hass, state)
def _get_template_state_from_state(hass: HomeAssistant, entity_id: str, state: (State | None)) -> (TemplateState | None):
    if (state is None):
        _collect_state(hass, entity_id)
        return None
    return TemplateState(hass, state)