Lovelace Fan Control Entity Row

I tried to find “Fan Control Entity Row” in the Community Add-ons and I don’t see it. I manually added it but when I reload the UI I get this:

Custom element doesn't exist: fan-control-entity-row.
entity: switch.garageafs_high_speed
type: 'custom:fan-control-entity-row'
name: Garage Air Filter
customTheme: false

I have the js file in the config/www directory and in my ui-lovelace.yaml file I have

title: My Home
  - url: /root/config/www/fan-control-entity-row.js
    type: js

and also:

      - type: entities
        title: Garage AFS
        show_header_toggle: false
          - entity: switch.garageafs_high_speed
            type: custom:fan-control-entity-row
            name: Garage Air Filter
            customTheme: false

Right now I’m just trying to test getting the card to display as I have a Sonoff 4 Channel Pro hooked up to an air filtration system that uses 3 separate relays for the speed control. I know I’ll have to do some work to get that actually working correctly but I thought I’d start with the UI first since the individual switches work in the UI now.

That’s because it’s not in the hassio add-ons. It’s installed thru the HACS custom component:

And normally when you have to install components manually and the file is located in the /www/ directory you have to add them to the lovelace config like:

title: My Home
  - url: /local/fan-control-entity-row.js
    type: js

in this case “/config/www/” = “/local/”

OK, it’s been a few years since I messed with HA so I’m back to being a noob. I had tried using just like in your example and got the error so I thought wasn’t finding the js file.

I don’t have HACS installed but I think for now I’ve accomplished the same result or should I undo my changes and go through the HACS path?

I always recommend using HACS. It (almost… :wink:) makes things idiot proof.

As long as you follow the instructions in the install page of HACS for each component exactly as written regarding the way to add it your resources section in Lovelace you will be fine there.

But if you think you have it done correctly otherwise (in the above you don’t…) then you can do it that way too.

But HACS is just way easier.

OK, I think installing HACS was more steps than what I did before but I just restarted and the card is loaded properly with the buttons now so that’s a step forward.

Now I just need to figure out how to get this to work with my setup. Each speed is just a different POWER command, Low is Power1, Medium is Power2, High is Power3:

- platform: mqtt
  name: "GarageAFS Low Speed"
  state_topic: "stat/Garage_AFS/POWER1"
  command_topic: "cmnd/Garage_AFS/POWER1"
  availability_topic: "tele/Garage_AFS/LWT"
  qos: 1
  payload_on: "ON"
  payload_off: "OFF"
  payload_available: "Online"
  payload_not_available: "Offline"
  retain: true

I’m not sure how that will work.

You will have to find someway to translate each “speed” into a combined “fan” entity that sends the different command topics for each speed and retrieves the fan state and speed for each speed.

you might take a look at my config for converting a “dumb” fan that uses an rf transmitter that doesn’t have any speed/state feedback into a fan entity for use with the control row.

it’s here and the section you are looking for starts on row 41. Be warned that it’s pretty long and involved tho:

OK, thanks for the tip. In my old setup I had created an automation (jet_afs.yaml) and then in my groups.yaml I had this:

  name: Jet AFS Speed
  control: hidden
    - input_select.afs_speed

This is all from a few years ago so some of those brain cells are dead now :wink:

OK, I’ve been digesting your code and reviewing what I had done a few years ago and fortunately there are a lot of similarities. I do have a couple of questions though:

  • sunroom_fan_off:
      alias: Sunroom Fan Off
        - service: switch.turn_on
          entity_id: switch.sunroom_fan_0
          # data:
            # packet: 'JgA0ACsMKw0PKA8pDygPKQ8oKw0PKA8oDykPAAEGKw0qDQ8pDygPKA8pDygrDQ8oDykPKA8ADQUAAAAA'
        - service: input_boolean.turn_off
            entity_id: input_boolean.sunroom_fan_state ```

If you’re turning off the fan why do you start with - service: switch.turn_on?

  • In your automations section you have a bunch of toggles where you turn on for 1 second and then turn off. Are those code blocks used anywhere? I think only the script section is actually used and maybe those are for something else?

Scripts are new to me and I currently only have automations defined. Is there a reason to use a script block over an automation block?

Those are really good questions.

It’s been so long since I’ve looked at the code I really can’t remember the details anymore.

I’ll have to dig in myself and try to jog my memory.

Or maybe it’s all just bad coding that I did a long time back and things need to be changed to make more sense. it really could go either way at this point. :laughing:

OK, I feel the same so no worries! I’m making changes now to see if I can get this to work. I haven’t messed with packages before but I can see how useful it is to keep everything in 1 spot.

I’ve got it all working now, it’s a bit messy but at least it works. I’m on to my next challenge and thought I’d ask here first before I start from scratch. I’d like to enhance this now so that you have an option to run the fan for a set amount of time. I’m thinking either a fixed button choice for time (say 30, 60, 90min) or a slider that jumps by 30min steps (I want this to be easy to use with a touch screen).

So the fan operation works the same but if you select a time the fan will run for that set time and then turn off.

I’ve never done that but I think it should be easy enough with an automation. you could either use a timer entity and start the timer with the desired time duration and turn off the fan when the timer is finished.

Or you could do it with a delay in the automation but I think that needs to be hard coded into the automation. So option one would be better.

You could set the timer duration with an input datetime, input number or input slider. for the input number or input slider you will need two - one for hours and one for minutes since minutes can’t be more than 59 (I think…).

OK, looks like I’m back to the research but I figured it wouldn’t hurt to ask. I think I need to create something that has the timer entity and then change my existing automation to check that timer entity and if set run for that duration and then turn off.

I’ve just released an update to the plugin based ion this (very old :flushed:) issue. I’m really sorry about letting that one slip under the radar for so long…

But it fixes a bug from when I updated it to work with my iFan02 flashed with ESPHome which needed the state (on) to be sent along with the speed command.

I didn’t realize that it would break functionality for other fans,

This update adds an option “sendStateWithSpeed” (which defaults to false) to maintain that functionality for fans that still need it but should restore functionality to those that don’t.

If you update and everything still works then great! You have nothing else to do.

If you find your speed buttons don’t work (especially if you use ESPHome) try adding the new config option back in and everything should then work just like it did before the update.

Hi @finity according, to the github issue.

I’m facing iFan03 problem with latest Tasmota (8.1.0) and MQTT
My OFF button is disabled and doesn’t send stat/RESULT = {“FanSpeed”:0}
All other buttons send correct speeds (1 for LOW, 2 for MID and 3 for HIGH)

When I try to set “off” from dropdown menu in entity view, works fine. The problem is only with button.

Thanks for popping in here for this.

I was just on the verge of closing that other issue and didn’t want you problem to be lost.

But on to your issue…

I don’t know if tasmota has changed anything with the code (I use 6.1.1 I think) but I don’t think it should have changed the basic functionality of the iFan03.

Could you post your code that you have for the iFan03 from HA?

The plugin won’t send stat/RESULT when you click the button. It should send “fan.turn_off” service to your entity_id. Then HA will send a command with 0 in the payload to your speed topic (cmnd/YOUR_TOPIC/FanSpeed) via your MQTT broker. Then when the fan turns off the fan will send a response to the broker to the state topic (stat/YOUR_TOPIC/RESULT) with a {“FanSpeed”: 0} in the payload. and the HA receives that message and sets the state of the fan to off.

At least that’s how mine works.

Do you have an MQTT sniffer to see what the messages are that get sent around when you turn on & off your fan? if not I recommend MQTTFx.

My HA config:

 - platform: mqtt
   name: "ifan03-borys Fan"
   command_topic: "ifan03-borys/cmnd/FanSpeed"
   speed_command_topic: "ifan03-borys/cmnd/FanSpeed"
   state_topic: "ifan03-borys/stst/RESULT"
   speed_state_topic: "ifan03-borys/stat/RESULT"
   state_value_template: >
     {% if value_json.FanSpeed is defined %}
       {% if value_json.FanSpeed == 0 -%}0{%- elif value_json.FanSpeed > 0 -%}4{%- endif %}
     {% else %}
       {% if == 'off' -%}0{%- elif == 'on' -%}4{%- endif %}
     {% endif %}
   speed_value_template: "{{ value_json.FanSpeed }}"
   availability_topic: ifan03-borys/tele/LWT
   payload_off: "0"
   payload_on: "4"
   payload_low_speed: "1"
   payload_medium_speed: "2"
   payload_high_speed: "3"
   payload_available: Online
   payload_not_available: Offline
     - "off"
     - low
     - medium
     - high

Lovelance card config:

  - customTheme: false
    entity: fan.ifan03_borys_fan
    name: Ceiling Fan
    type: 'custom:fan-control-entity-row'
show_header_toggle: false
title: Borys
type: entities

I’m using MQTT Explorer

you have a typo in your fan config.

state_topic: "ifan03-borys/stst/RESULT"

should be:

state_topic: "ifan03-borys/stat/RESULT"

stst -> stat

try that and see if it works for you.

1 Like

OMG, you’re right!
Now, works like a charm
Thanks and sorry for that

:wink: :+1: