finity69x2 / fan-control-entity-row

Provides a means to show a compact graphical control row for 2 or 3 speed fans in Home Assistant
68 stars 27 forks source link

Anyway to make group.allfans work? #19

Closed ctrl50 closed 4 years ago

ctrl50 commented 4 years ago

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

ctrl50 commented 4 years ago

Peek 2020-04-23 00-20

finity69x2 commented 4 years ago

Can you run the various fan services on the group? Especially the "fan.set_speed" service? From your gif I assume that you can.

What is the state of the entity "group.airmovers" when you turn the group on & off? and is there a "speed" attribute for your group when you switch the group to different speeds?

I don't have any fan groups to test against but I could probably make one if I need to.

Thanks for the kind words. I kind of knew this control row would be useful but I never really expected the button & light control rows to be that popular but I was definitely wrong.

ctrl50 commented 4 years ago

The state of the group is either, off when off, or on when in any speed. No speed attribute at all.

fan.set_speed
entity_id: group.airmovers
speed: high

does work

Yeah the button rows are very slick, great job on it.

finity69x2 commented 4 years ago

I figured that was the case so then the issue is going to be that the fans provide a "speed" attribute that your group doesn't provide.

I'm not sure I will be able to work around that limitation of the group.

the best way to do it might be for you to create a template fan that uses the state of the group for the state of the template fan and then create a speed_template that calculates the "speed" attribute of the template fan based on the speeds of all of the fans in the group. It's going to get a bit complicated if you do it that way tho but it should be possible (I think...).

But you have to find a way to get a speed attribute to pass to the control row for it to register the speed setting of the group. Which in turn will give you the proper feedback to set the states of the speed buttons for the group.

ctrl50 commented 4 years ago

hmmm. ill have to read over that again LOL

This is what i have setup for controlling the fans right now.

kitchen_fan_off:
  alias: Kitchen Fan Off
  sequence:
  - service: fan.turn_off
    data:
      entity_id: fan.kitchen
kitchen_fan_on:
  alias: Kitchen Fan On
  sequence:
  - service: fan.turn_on
    data:
      entity_id: fan.kitchen
  - delay:
      seconds: 1
  - service_template: >-
      {% if is_state("input_select.kitchen_fan_speed", "low") %}
        script.kitchen_fan_low
      {% elif is_state("input_select.kitchen_fan_speed", "medium") %}
        script.kitchen_fan_medium
      {% elif is_state("input_select.kitchen_fan_speed", "high") %}
        script.kitchen_fan_high
      {% endif %}
kitchen_fan_low:
  alias: Kitchen Fan Low
  sequence:
  - service: fan.turn_on
    data:
      entity_id: fan.kitchen
  - service: fan.set_speed
    data_template:
      entity_id: fan.kitchen
      speed: low
kitchen_fan_medium:
  alias: Kitchen Fan Med
  sequence:
  - service: fan.turn_on
    data:
      entity_id: fan.kitchen
  - service: fan.set_speed
    data_template:
      entity_id: fan.kitchen
      speed: medium
kitchen_fan_high:
  alias: Kitchen Fan High
  sequence:
  - service: fan.turn_on
    data:
      entity_id: fan.kitchen
  - service: fan.set_speed
    data_template:
      entity_id: fan.kitchen
      speed: high
kitchen_fan_set_speed:
  alias: Set Kitchen Fan Speed
  sequence:
  - service: input_select.select_option
    data_template:
      entity_id: input_select.kitchen_fan_speed
      option: '{{ speed }}'
  - service: script.turn_on
  - service_template: >-
      {% if is_state("input_select.kitchen_fan_speed", "low") %}
        script.kitchen_fan_low
      {% elif is_state("input_select.kitchen_fan_speed", "medium") %}
        script.kitchen_fan_medium
      {% elif is_state("input_select.kitchen_fan_speed", "high") %}
        script.kitchen_fan_high
      {% endif %}

same thing for the living room fan. I know I could probably shorten it up some.. but havent got to that yet.. hmm

ctrl50 commented 4 years ago

Im confused at how it knows to adjust the speed just by calling the group entity? because before I installed your button component, it just called scripts that set the fanspeed. When I call the group from your component it doesnt' call those scripts, but it does set the proper speed... I guess like you said it just doesnt know the state. it obviously knows to call the right speed, when i hit the right button... hmmm

ctrl50 commented 4 years ago

So im guessing it would be more along the lines of:

- platform: template
  fans:
    kitchenfan:
      friendly_name: "Kitchen Fan NOT main"
      value_template: "{{ states('fan.kitchen') }}"
      speed_template: "{{ states('input_select.kitchen_fan_speed') }}"
      turn_on:
        service: fan.turn_on
        entity_id: fan.kitchen
      turn_off:
        service: fan.turn_off
        entity_id: fan.kitchen

      set_speed:
        service: fan.set_speed
        entity_id: fan.kitchen

        data_template:
          speed: "{{ speed }}"
      speeds:
        - 'low'
        - 'medium'
        - 'high'
finity69x2 commented 4 years ago

I'll have to play around with it some. I have an idea starting to come together but I'll need to test it.

Give me a bit. It could be a couple of days tho.

ctrl50 commented 4 years ago

No problem, im currently working on template attributes as a workaround. Ill post up if i get something working. Thanks.

finity69x2 commented 4 years ago

I've worked out a way to do what you want.

It's not really that complicated but there are a couple of parts you need to create. There might be an easier way to do it but this works and is tested:

I don't know if you've ever worked with packages but if you have you can just copy the below code into a package file and after changing the names of the fans in the scripts to match yours it should all work. If not the just copy each piece under it's appropriate section in your configuration.yaml or the appropriate !include file as needed.

input_boolean:
  all_fans_state:
    name: All Fans State

input_select:
  all_fans_speed:
    name: All Fans Speed
    options:
      - 'low'
      - 'medium'
      - 'high'

fan:
  - platform: template
    fans:
      all_fans:
        friendly_name: "All Fans"
        value_template: "{{ states('input_boolean.all_fans_state') }}"
        speed_template: "{{ states('input_select.all_fans_speed') }}"
        turn_on:
          service: script.all_fans_on
        turn_off:
          service: script.all_fans_off
        set_speed:
          service: script.all_fans_speed
          data_template:
            speed: "{{ speed }}"
        speeds:
          - 'low'
          - 'medium'
          - 'high'

script:
  all_fans_on:
    sequence:
      - service: fan.turn_on
        entity_id:
          - fan.ifan02_test_fan
          #- fan.master_bedroom_fan
          - fan.sunroom_fan
      - service: input_boolean.turn_on
        entity_id: input_boolean.all_fans_state
  all_fans_off:
    sequence:
      - service: fan.turn_off
        entity_id:
          - fan.ifan02_test_fan
          #- fan.master_bedroom_fan
          - fan.sunroom_fan
      - service: input_boolean.turn_off
        entity_id: input_boolean.all_fans_state
  all_fans_speed:
    sequence:
      - service: fan.turn_on
        entity_id:
          - fan.ifan02_test_fan
          #- fan.master_bedroom_fan
          - fan.sunroom_fan
      - service: input_boolean.turn_on
        entity_id: input_boolean.all_fans_state
      - service: fan.set_speed
        data_template:
          entity_id:
            - fan.ifan02_test_fan
            #- fan.master_bedroom_fan
            - fan.sunroom_fan
          speed: '{{speed}}'
      - service: input_select.select_option
        data_template:
          entity_id: input_select.all_fans_speed
          option: '{{speed}}'
ctrl50 commented 4 years ago

i was so close. I had it all going except the entity wasn't turning on because I left out the input_boolean.

Peek 2020-04-28 22-25

Thanks a lot.

here is a screen of my main page

Screenshot_20200428_223955

ctrl50 commented 4 years ago

Solved. Thanks again.

finity69x2 commented 4 years ago

That UI looks pretty good. I really like those button controls. :)

Glad it's working for you. Maybe I'll post the solution in the readme so it might help others.

ctrl50 commented 4 years ago

Thanks, its a little cluttered but I like having most of the stuff on 1 page, it scrolls down another full screen too lol.

And the rest of my tabs.. its A lot. and I mean a lot going on. I wish HA had a way to save a view and delete it. Node-red needs this too. I have just as many things going on in NR.

You should add it to the documents. One thing I find lacking even after a year with this stuff is the documents are always lacking. I guess its due to the infinite possibility's with differing configurations. I still to this day, find HA docs for things I never even knew existed too. The fan documents are lacking immensely as with most others. I know, I can open pr's to update them but Im far to ignorant and very much still learning/making mistakes,.

Thanks again.