Problem with fan entity (it thinks that it's a light)

I hope someone can help. I don’t understand what’s going on.

I have a zb powered switch that’s switching a fan. This went well for several months after someone told me to add this to a config file:

platform: template
fans:
  bathroom_big_fan:
    friendly_name: "Bathroom Big Fan"
    value_template: "{{ is_state('light.bathroom_big_fan', 'on') }}"
    turn_on:
      service: light.turn_on
      target:
        entity_id: light.bathroom_big_fan
    turn_off:
      service: light.turn_off
      target:
        entity_id: light.bathroom_big_fan

After adding that it worked and HASS didn’t think it was a light anymore. But after the latest update, my automations stopped working and it’s now a light again.

I never understood why HASS thinks that a generic power switch is a light.

Can anyone help me with this? I really want the fan to work again. I have no idea what I’m doing.

First off your config will fail outright in 5 months, you should have a repair warning for that. You can read up on what a template fan entity should actually look like in the Template Integration Docs, it’ll also help with the “I have no idea what I’m doing.” issue.

What does the switch actually look like in HA? Go to the device page and click on the entity, take a screen shot, and post it back here.

It will likely also help if you can post what you’re using to trigger your automations that are no longer working.

“First off your config will fail outright in 5 months, you should have a repair warning for that.”

I did see a warning about an automation and I fixed that one assuming that was it.

I hope these screenshots help.

I don’t understand the template integration doc you gave me. I have no idea what to do with it. Looks similar to what I have now

Similar is not equal to the same. Go to Settings > System > Repairs and the click the 3 dot menu in the upper right corner and check ‘Show ignored repairs’, see if you have anything then.

As to your screenshots you stopped just before the important part, what do you get when you click the ‘Actions:’ > Fan ‘turn on’ Unknown entity?

It looks similar and I don’t know what to do with that page. It links me to general information.

I don’t even know how I ended up in this mess. That device was never a light nor meant to be a light. I’m very confused why Home Assistant thinks a generic device is a lightbulb instead of asking what it is.

Here you go. The error is gone, it’s not under ignored. Didn’t solve the problem but the error is gone

I didn’t see a notification that someone replied in my mail, which I assumed I would get. Otherwise I would have responded sooner.

Replace your fan template with this new format version, you should get your fan entity back

template:
  - fan:
      - name: "Bathroom Big Fan"
        state: "{{ states('light.bathroom_big_fan') }}"
        turn_on:
          action: light.turn_on
          target:
            entity_id: light.bathroom_big_fan
        turn_off:
          action: light.turn_off
          target:
            entity_id: light.bathroom_big_fan

Or, if you’re not bothered about it being a fan entity, just change the action in your automation to ‘Light Turn on’ instead of ‘Fan Turn on’ and select the light entity.

I think the issue lies with the device and the way it publishes its info that makes HA see it as a light, I had one that did it a few years ago, but Z2M updated and it changed eventually. If you raise an issue on github (assume you are using ZHA and not Z2M) you might be able to get someone to do a translation (not sure that’s the right term, maybe ‘quirk’ ?)

Assuming you only have this one template entity in your configuration.yaml file you can change your original configuration to what Holdestmade posted above… similar but not the same.

If you already have a template: key in the file then just paste everything after it, if not paste the whole thing.

Although a simpler, more maintainable, and UI friendly fix might be to just go to Settings > Devices & services > Helpers then click Create helper in the lower right and use the ‘Change device type of a switch’. Select the switch and choose ‘Fan’ as its new device type. Then use the new ‘fan’ entity in your automations, it’s pretty bullet proof.

If you go this route just remember to remove your original template entity from configuration.yaml and restart Home Assistant to avoid any conflicts.

I am bothered about it because it messes up with the audio part so if i turn off the lights, the fan goes off too. quite annoying. it also shows as a fan.

I copy pasted it and rebooted and it’s still a light

however, i created a new fan automation and that appears to work:

So at least the automation works but when i tell it to turn off the lights, the fan goes off too.

The light entity will still exist but there should also be a fan entity, there must be one as you are using in your automation ? Not sure if you can disable the light now, not sure if that will stop the template fan working

I didn’t realize that was even an option. I just tried to do that to see if that would work and I can’t select it:

Even tried removing the template that Holdestmade gave me and restarted home assistant without any luck

The only think I see is a light. Just readded the config you gave me and restarted home assistant.

Anything in the logs about it ?

Also, you can just reload templates without restarting in dev tools

@HappyCadaver Pretty sure the ‘Change device type of a switch’ only works for switches and not lights

Right, figured it was worth a shot.

I’m lost here… the modern template entity you provided should work, and there should be one light entity and one fan entity. At that point you should be able to hide the light entity, maybe something in the way zigbee works? I have no experience there.

Well I can use it in the automation now but it’s still a light. It’s confusing to me. I don’t know what to provide as new information. It’s a light and it shouldn’t be one. At least the automation works but it’s not what I hoped it would be.

Just to be sure, this is what I have:

I don’t understand how it would turn it into a fan

It won’t turn it into a fan you’ll get a fan entity as well. I’m not sure you have it configured correctly, what is in your config.yaml ? try pasting this straight into config.yaml. or look here and see how to do it in your fans.yaml file

template:
  - fan:
      - name: "Bathroom Big Fan"
        state: "{{ states('light.bathroom_big_fan') }}"
        turn_on:
          action: light.turn_on
          target:
            entity_id: light.bathroom_big_fan
        turn_off:
          action: light.turn_off
          target:
            entity_id: light.bathroom_big_fan

/homeassistant/fans.yaml

What kind of Home Assistant installation are you using? Regardless what this template does is creates a fan entity based on the state of your ‘light’ entity, the light entity will still exist and the fan entity wouldn’t work without it.

Holdestmade beat me to it, but how you’re including this file in configuration.yaml is important here for it to show up as an entity that you can use.

That said it does seem redundant to me as it just mimics the ‘light’ entity anyways. If you’ve got the automation working, and you’ve got it looking like a fan in the front end as a fan now, the only real tangible difference is what you see in the more info dialogue.

Problem is its classed as a light for Assistant - “turn all the lights off” … think someone mentioned that earlier. With a templated fan you can expose the fan to Assistant and not the light

Just found this post with same issue and a way to solve it if you are using ZHA