Code Monkey home page Code Monkey logo

fan-control-entity-row's Introduction

Fan Control Entity Row

This is an element to add a fan control row to Home Assistant.

This plugin is only valid for use with fans that still use a speed list in the fan configuration. That fan control model is deprecated in versions of Home Assistant 2021.3.x and later. For HA versions 2021.3.x and later use fan-percent-button-row or fan-mode-button-row if your fan has been updated to use the new control methods.

It uses the code that can be found in my fan control package @ https://github.com/finity69x2/Home-Assistant/blob/master/packages/fan_package.yaml

UPDATE:

I've added the ability to hide the medium speed button to turn it into a two speed fan control, as well. To use it in this mode then your fan speeds must be designated low and high since it simply removes the medium speed button.

Installation:

The easiest way to install this is to use the Home Assistant Community Store (HACS) in Home Assistant.

Follow the instructions there for installation making sure you note the "url:" section for the resources addition.

Conversely, if you don't use HACS you can install it manually by performing the following:

Copy the fan-control-entity-row.js file to the appropriate folder in your Home Assistant Configuration directory (/config/www/).

Place the following in your "resources" section in your lovelace configuration (updating the localation to where you placed the above file):

  - url: /local/fan-control-entity-row.js
    type: module

Then to use this in a card place the following in your entity card:

Options:

Name Type Required Default Description
entity String Yes none a fan entity_id
type String Yes none custom:fan-control-entity-row
name String No none A custom name for the entity in the row
customTheme Boolean No false set to true to use a custom theme
reverseButtons Boolean No false Set to true to reverse the button order
isTwoSpeedFan Boolean No false Set to true to hide the Medium Speed button
hideOff Boolean No false Set to true to hide the Off button
sendStateWithSpeed Boolean No false Used only for certain firmware that requires the State command be sent with the Speed command
width String No 30px A custom width for the buttons
height String No 30px A custom height for the buttons
isOffColor String No '#f44c09' Sets the color of the 'Off' button if fan is off
isOnLowColor String No '#43A047' Sets the color of the 'Low' button if fan is on low
isOnMedColor String No '#43A047' Sets the color of the 'Med' button if fan is on Medium
isOnHiColor String No '#43A047' Sets the color of the 'Hi' button if fan is on high
buttonInactiveColor String No '#759aaa' Sets the color of the the buttons if that selection is off
customOffText String No 'OFF' Sets the text of the "off" button
customLowText String No 'LOW' Sets the text of the "low" speed button
customMedText String No 'MED' Sets the text of the "medium" speed button
customHiText String No 'HIGH' Sets the text of the "High" speed button
state_color Boolean No false Sets the icon color of the entity to reflect the current state

The values for the colors can be any valid color string in "HEX", "RGB" or by color name.

*NOTE: The speeds that your fan uses in Home Assistant need to use all lowercase letters. The only time this should be a concern is if you are using a template fan. Be sure to make your speeds all lowercase in the fan configuration.

The optional "sendStateWithSpeed" config entry is only needed to be set to true if for some reason your fan needs the state command of "on" to be sent along with the desired speed command. As far as I know this is only needed for use with fans flashed with the ESPHome Firmware.

Comfguration Examples:

  cards:
    - type: entities
      title: Fans
      show_header_toggle: false
      entities:
      ## USE THIS CONFIG TO HAVE IT MATCH YOUR THEME ##
        - entity: fan.master_bedroom_fan
          type: custom:fan-control-entity-row
          name: MBR Fan Not Custom
          customTheme: false
      ## USE THIS CONFIG TO USE A DEFAULT CUSTOM THEME
        - entity: fan.sunroom_fan
          type: custom:fan-control-entity-row
          name: Sunroom Fan Default Custom
          customTheme: true
      ## USE THIS CONFIG TO USE A 'CUSTOMZED' CUSTOM THEME
        - entity: fan.sunroom_fan
          type: custom:fan-control-entity-row
          name: Sunroom Fan Custom Custom
          reverseButtons: true
          customTheme: true
          isOnLowColor: 'rgb(255, 0, 0)'
          isOnMedColor: '#888888'
          isOnHiColor: '#222222'
          buttonInactiveColor: '#aaaaaa'
          isOffColor: 'purple'
      ## USE THIS CONFIG FOR USE WITH THE ESPHOME FIRMWARE (ALONG WITHE THE THEME SETTING ABOVE IF DESIRED)
        - entity: fan.master_bedroom_fan
          type: custom:fan-control-entity-row
          name: MBR Fan Not Custom
          sendStateWithSpeed: true
      ## USE THIS CONFIG TO SET CUSTOM BUTTON TEXT (NOT REQUIRED TO SET "customTheme: true" TO USE THESE )
        - entity: fan.sunroom_fan
          type: custom:fan-control-entity-row
          name: Sunroom Fan Custom Custom
          customHiText: me
          customLowText: do
          customMedText: re
          customOffText: not
          width: '15px'
          height: '15px'

This is with the default Lovelace frontend theme set:

Default

This is with the "Slate" frontend theme set:

Slate

This is how this plugin looks with the Light Brightness Preset & Binary Button Rows:

Slate-Compare

fan-control-entity-row's People

Contributors

alryaz avatar finity69x2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fan-control-entity-row's Issues

Off Button does nothing

The off button no longer works. I am using a BOND but the "off" event does work with scripts or sending the event manually.

Depreciated Java

Since the latest update I have noticed that the add-on now says it is depreciated in the Configuration>Lovelace>Resources section. It also fails to load half of the time which I think is related to that as I have other depreciated front end add-ons that are doing the same. I have to refresh a few times for it to display the card now. Not sure if there are any tweaks I can do on my end so I figured I would reach out here. Let me know if you need more info.

Feature request: 2-speed fan

Hello,
I have several bathroom fans with only two speeds. Would it be possible to hide/disable third speed in config?

Anyway to make group.allfans work?

Searched around, although admit-tingly not very thoroughly and didnt see anything related.

works:

      - customIsOffColor: 'rgb(128, 0, 0)'
        customIsOffSpdColor: '#121212'
        customIsOnHiColor: 'rgb(0, 128, 0)'
        customIsOnLowColor: 'rgb(0, 0, 128)'
        customIsOnMedColor: 'rgb(128, 128, 51)'
        customTheme: true
        entity: fan.living
        name: Ceiling Fan
        secondary_info: last-changed
        type: 'custom:fan-control-entity-row'

      - customIsOffColor: 'rgb(128, 0, 0)'
        customIsOffSpdColor: '#121212'
        customIsOnHiColor: 'rgb(0, 128, 0)'
        customIsOnLowColor: 'rgb(0, 0, 128)'
        customIsOnMedColor: 'rgb(128, 128, 51)'
        customTheme: true
        entity: fan.kitchen
        name: Kitchen Fan
        secondary_info: last-changed
        type: 'custom:fan-control-entity-row'

does not update buttons, but it does control the group:

      - customIsOffColor: 'rgb(128, 0, 0)'
        customIsOffSpdColor: '#121212'
        customIsOnHiColor: 'rgb(0, 128, 0)'
        customIsOnLowColor: 'rgb(0, 0, 128)'
        customIsOnMedColor: 'rgb(128, 128, 51)'
        customTheme: true
        entity: group.airmovers
        name: All Fans
        secondary_info: last-changed
        type: 'custom:fan-control-entity-row'

groups.yaml:

airmovers:
  name: All Fans
  entities:
    - fan.kitchen
    - fan.living

Anyway to make this work, or possibly an update to fix it?

Love these button components as I use both extensively.
Thanks

User friendly button view

Hi Guys, just signed up and not sure how to use this but. Can you help create a fan card thats user freindly, there only seem to be one card available and its not that user freindly. Im thinking something like the pic attached.

Screen Shot 2022-02-27 at 4 27 56 pm

Missing Auto Mode on some fans

My Air purifier has fan speed attributes, but also has a mode attribute.
image

If you manually select a speed, mode sets to 'manual'.
the purifier has an auto button. sets mode to Auto. Speed becomes null

image

If you could add option:

auto_button : true (default false)
Enables an Auto button, the Auto button sets mode attribute to auto,

Off state not working

EDIT: seems I misunderstood how sendStateWithSpeed was supporsed to work. That is not the issue...

I have a MQTT based fan that, for some reason, will not turn off when using v1.5 of this plugin w/ hass 0.110. Works w/ my 3 other Insteon based fans. From what I can see the service call fan.turn_off doesnt seem to be sufficient, but rather the fan expects fan.set_speed set to off..

Fan service calls changing

Heads up:
I'm on the dev build right now and I get this when I use this lovelace addon.
[homeassistant.components.fan] fan.set_speed is deprecated, use fan.set_percentage or fan.set_preset_mode instead.
Explanations of the new methods are here in the dev docs.
I don't know when this method is going away entirely, but this is coming at some point.

shrink excess gap when used in places that aren't an entities card + option to hide name altogether

Is it feasible to shrink the name area so there isn't a big gap when this element is used in places other than an entities card? Might it also be feasible to hide the name area entirely if name=false?

My use cases are in the picture elements card and in the custom banner-card. I'm going for a fairly tight layout on my dashboards and without the extra gap I could put 2 of these in the space 1 normally requires. The gap also makes the buttons seem unrelated to the icon and name on a picture elements card.

These adjustments would be handy as a consistent feature across all your custom elements.

The fan.set_speed service is deprecated

Home Assistant 2021.4.1
Fan Control Entity Row: 2.1

2021-05-05 12:47:13 WARNING (MainThread) [homeassistant.components.fan] The fan.set_speed service is deprecated, use fan.set_percentage or fan.set_preset_mode instead

No fan speed when HA restarts

I'm using this fan controller, and have it showing in lovelace. However, if a fan is on, and HA reboots, when it comes back up, the interface shows that the fan is off, even though it's still on.

How can I make it so the speed shows after reboots?

Support for changing order of turn_on and set_speed

For my fan, the current setting of speed is not working. In your code, first a set_speed is sent, and then a turn_on. This is not working for my fan: it first needs the turn_on and then the set_speed. Is it possible to add an option for this?

docs gone wild

There are 3 different places that tell you how to install this plugin and all 3 have different paths and plugin types.....

In this repo
Screen Shot 2020-03-02 at 8 27 27 PM

In the community post
Screen Shot 2020-03-02 at 8 27 55 PM

in HACS
Screen Shot 2020-03-02 at 8 27 01 PM

what gives? can we get a single consistent source of truth?

Button - unselected state

I currently have a BOND controller that sends the fan commands to my fans. The current plugin works great, however, it can end up 'out of sync' with my actual fan due to users interacting with the physical fan controller itself.

Example:

  1. User utilizes HA to set fan to High Speed
  2. User utilizes physical fan controller to set fan to Medium (HA or BOND has no awareness of this)
  3. Observe the HA Dashboard continues to display the fan speed at High (Step 1)

Suggestion 1: The ability for the UI to allow a user to select a setting/button but after the selection (ex: High Speed button), the button does not retain a 'IsOn' state but instead just immediately defers back to the 'IsOff' state. This way, the HA display is not out 'out of sync' with the actual physical state and strictly acts as a controller to send commands but automatically default back to 'IsOff'.

Suggestion 2: Allow the same state to be selected again (MEDIUM is currently selected but allow the user to select MEDIUM again). I can then simply change the style of the 'IsOn' and 'IsOff' state to be the same.

Request: Hide off button

Hi,

I'm using the fan-control-entity-row for my mechanical ventilation. This is something I can't turn off (which is common in the Netherlands with ITHO devices) so it should be nice to have the option to hide the off. Could this option be added?

Home Assistant Mobile App doesn't display entity

The element is terrific. I'm able to see it on my dashboards both on desktop and Mobile browsers. When I try to view it on the Home Assistant Android app I see errors.

Custom element doesn't exist: fan-control-entity-row.
entity: fan.fan_switch_family_room_level
type: 'custom:fan-control-entity-row'
name: Family Room
customTheme: false
reverseButtons: true

Apologies if this is the wrong way to post this.

Make custom theme false the default

I believe the custom theme should be set to false as default. Default behavior should match whatever theme the user specifies.

I also think even setting this to false, for some reason the theme is not matched completely.

Oscillation feature

Hi,

Is there any way to provide the oscillation feature for this card? I'm using smartir to control a Mitsubishi Fan and it would be great if we can switch the oscillation on or off.

Disable Unsupported Speed

I have a diffuser that I am treating as a fan. It only has 3 speeds: Low, High, and Off. Could there be a way of hiding the unsupporting ones?
Either

  1. Looking at the supported modes and just not show the button
  2. Have the user specify the button to hide.

Fan.set_speed servise is deprecated since 2022.3

Hi,

I am using your great tool - fan-control-entity-row but lately, it doesn't work properly. Could you update your code and change used service from fan.set_speed to fan.set_percentage? Fan.set_speed is deprecated since 2022.3

Thanks in advance
Radek

Custom background color since 1.8

Since version 1.8 the customIsOffSpdColor setting has no effect anymore.

Version 1.8 and 1.9:
image

Version 1.7:
image

Using the following card settings:

              - entity: fan.dyson_pure_cooltm
                name: Dyson
                type: 'custom:fan-control-entity-row'
                sendStateWithSpeed: true
                customTheme: true
                customIsOffColor: var(--primary-color)
                customIsOffSpdColor: var(--secondary-background-color)
                customIsOnHiColor: var(--primary-color)
                customIsOnLowColor: var(--primary-color)
                customIsOnMedColor: var(--primary-color)
                state_color: true

Speed in off state

Hi

If the fans is in off state, clicking on any speed should allow for the fan to be turned on in the speed selected. Clicking on the device to turn on then select speed defeats the purpose of this card.

Rishab

Buttons can't be clicked

Using Fan Mode Button Row via Hacs, HA 2021.5.5 on a PI4 Safari 14.1 with and without iOS/MacOS Apps. Fancontroller is a Sonoff iFan02 Tasmotized with 9.3.1

Lovelace:

entity: fan.fan_sz
type: 'custom:fan-mode-button-row'
name: Schlafzimmer
reverseButtons: true

Problem is, i can't click on all of the 4 Buttons, but no reactions. In the more-info Dialog i can change the speed flawless, can even do so by Servicecalls.

What i did so far:

  • Reinstalled Fan Mode Button Row
  • Reinstalled Fan Mode Button Row again, with manual cleaning/checking
  • Reinstalled HACS
  • Installed Fan Mode Button Row
  • ...

Of course i restarted HA every time, and cleared cache frequently.

I still donno if it is a Bug or if i did something wrong.

Make the speed display entries configurable, take the speed entries from speed_list

I tried to set up a fan and integrated it to lovelace with your control. I assume my setup is somehow wrong:

  • Installed it via HACS, current version is 1.5
  • Configured fan via fan template, it works through developer tools, I tried fan.turn_on, fan.turn_off, fan.toggle and fan.set_speed
  • In developer tools the fan state reports
speed_list:
  - '1'
  - '2'
  - '3'
speed: '1'
friendly_name: Wohnraumlüftung
supported_features: 1

The fan template looks like:

fan:
  - platform: template
    fans:
      ventilation_fan:
        friendly_name: "Wohnraumlüftung"
        value_template: >-
          {% if states('switch.switch_ventilation_relay_1') == 'on' %}
            off
          {% else %}
            on
          {% endif %}
        speed_template: >-
          {% if states('switch.switch_ventilation_relay_2') == 'on' %}
            2
          {% elif states('switch.switch_ventilation_relay_3') == 'on' %}
            3
          {% else %}
            1
          {% endif %}
        turn_on:
          service: switch.turn_off
          data:
            entity_id: switch.switch_ventilation_relay_1
        turn_off:
          service: switch.turn_on
          data:
            entity_id: switch.switch_ventilation_relay_1
        set_speed:
          service_template: >-
            {% if speed == '1' %}
              script.ventilation_fan_1
            {% elif speed == '2' %}
              script.ventilation_fan_2
            {% elif speed == '3' %}
              script.ventilation_fan_3
            {% endif %}
        speeds:
          - '1'
          - '2'
          - '3'

I integrated it in lovelace with

  - type: entities
    title: Belüftung
    show_header_toggle: false
    entities:
    - entity: fan.ventilation_fan
      type: custom:fan-control-entity-row
      name: Wohnraumlüftung

The control is displayed as
image

but the buttons are not initialized correctly and are not selectable - the state was

speed_list: 1, 2, 3
speed: 1
friendly_name: Wohnraumlüftung
supported_features: 1

and state on, so "LOW" should have been selected.

My home assistant version is

arch armv7l
chassis embedded
dev false
docker true
hassio true
host_os HassOS 4.8
installation_type Home Assistant
os_name Linux
os_version 5.4.42-v7l
python_version 3.7.7
supervisor 226
timezone Europe/Vienna
version 0.110.4
virtualenv false

The theme is https://github.com/JuanMTech/google_dark_theme

Changes are high that I did something wrong, would be glad if you could point me in the right direction.

Typo in Options table

Not a big deal, but I troubled a bit with this before I noticed it.

image

Just to let you know :)

Change to support Sonoff iFan02 .. breaks speed setting to low or high when using Insteon FanLinc

Pressing the high button sets the speed properly then a second or so later, sets the speed to medium. A plain switch on with Insteon FanLinc always sets the speed to medium.

Removing this line restores the previous behavior for me
line 209 this.hass.callService('fan', 'turn_on', {entity_id: this._config.entity});

I also edited these line to make buttons bigger for me... an enhancement to adjust button size would be nice

                min-width: 65px;
	    max-width: 65px;
	    height: 65px;

            font-size: 12px !important;

Otherwise great code thanks for sharing

Request: Hide off button

Hi,

I'm using the fan-control-entity-row for my mechanical ventilation. This is something I can't turn of,f so it should be nice to have the option to hide the off. Could this option be added?

⚠️ Information: Future card configuration changes.

Hi.

A change in how lovelace cards are set up in Home Assistant 0.105 increases performance, but enables cards to accidentally modify their own configuration in the loaded lovelace configuration.

I'm going through the cards in the HACS default repository, and noticed that your card may be susceptible to this. Looking through your code it seems you may modify parts of the config object passed to your card in setConfig.

The result could be that your card does not work well with the GUI editors or that parts of the configuration start showing up multiple times.

At some point in the future, it is likely that the configuration will be frozen before being passed to setConfig. At this point, your card will fail entirely when it tries to modify the configuration object.

There are several ways to fix/protect agains this problem.

The best is to restructure setConfig such that the configuration is never modified.
Other alternatives are to make a copy of the configuration and work on that instead.

setConfig(config) {
  config = { ...config }; // This works for simple configurations not containing arrays or objects
...
import { deepClone } from "deep-clone-simple";
// https://github.com/balloob/deep-clone-simple

setConfig(config) {
  config = deepClone(config); // This is a safe and fast method
...

or

setConfig(config) {
  config = JSON.parse(JSON.stringify(config)); // This uses built-in functions, but may be slower than deepClone
  ...

Please note that I have not tested your card agains Home Assistant 0.105 or later, but just quickly looked through the code. If I'm mistaken in my assessment, I appologize for taking your time.

See thomasloven/hass-config#6 for more info.

Turning fan to "off" causes fan to set speed to "3"

Using the Bond integration with 4 run-of-the-mill remote-controlled fans.

lovelace ui:

cards:
  - type: entities
    show_header_toggle: false
    title: Ceiling fans
    entities:
    - entity: fan.office_fan_3
      type: custom:fan-control-entity-row
      name: Office fan
      customTheme: false

Whenever I attempt to turn the fan off, the fan instead set its speed to 3. The logs show it:

# initial state is off 
Sep 25 15:25:10 cube docker-compose[3376158]: home-assistant   | 2020-09-25 15:25:10 DEBUG (MainThread) [homeassistant.components.bond.entity] Device state for fan.office_fan_3 is:
Sep 25 15:25:10 cube docker-compose[3376158]: home-assistant   | {'power': 0, 'speed': 3, 'direction': 1, 'light': 1, '_': '449c0000'}

# turn the fan on (speed 1)
Sep 25 15:25:23 cube docker-compose[3376158]: home-assistant   | 2020-09-25 15:25:23 DEBUG (MainThread) [homeassistant.components.bond.entity] Device state for fan.office_fan_3 is:
Sep 25 15:25:23 cube docker-compose[3376158]: home-assistant   | {'power': 1, 'speed': 1, 'direction': 1, 'light': 1, '_': '276a1988'}

# turn the fan off (speed is set to 3) ????
Sep 25 15:25:34 cube docker-compose[3376158]: home-assistant   | 2020-09-25 15:25:34 DEBUG (MainThread) [homeassistant.components.bond.entity] Device state for fan.office_fan_3 is:
Sep 25 15:25:34 cube docker-compose[3376158]: home-assistant   | {'power': 1, 'speed': 3, 'direction': 1, 'light': 1, '_': '4b031e4f'}

Commenting out the set_speed call that is made when turning off the fan seemed to solve the issue:

	setSpeed(e) {
		const speed = e.currentTarget.getAttribute('name');
		if( speed == 'off' ){
			this.hass.callService('fan', 'turn_off', {entity_id: this._config.entity});
			// this.hass.callService('fan', 'set_speed', {entity_id: this._config.entity, speed: speed});
		} else {
			if(this._config.sendStateWithSpeed){
			this.hass.callService('fan', 'turn_on', {entity_id: this._config.entity});
			}
			this.hass.callService('fan', 'set_speed', {entity_id: this._config.entity, speed: speed});
		}
	}

I'm sure that call was put there at some point for a reason, but it sure breaks things for me.

Error with HA > V2021.3.X

With the new fan percentage system, this plugin is now throwing an error:
Failed to call service fan/set_speed. invalid literal for int() with base 10: 'low'

Is there a way to get this working with the new fan model, or do I need to replace it with fan-percent-button-row for all of my fans?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.