close, you need the entity id in quotes. And because of the quotes on the outside, you need to use different quotes. Also, I think it still treats it as ‘on’ / ‘off’, so you should be using is_state
{% set my_hours = states.input_text.iframe.state.replace('[','').replace(']','').replace(' ','').split(',') %}
{% if now().hour | string in my_hours %}
on
{% else %}
off
{%- endif -%}
You cannot use that because it will not update in real time because the now() object does not trigger updates to the template.
EDIT: So what would happen is, it would only update when you change input_text.iframe. So for example, if it was 8am, and you hadn’t changed input_text.iframe since 4pm the day before. The sensor would still have the input_text.iframe 4pm sensor state, not the the current time at 8am.