Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Card Fan as a New Base Card #1194

Merged
merged 16 commits into from
Mar 10, 2023
Merged

Card Fan as a New Base Card #1194

merged 16 commits into from
Mar 10, 2023

Conversation

benbur98
Copy link
Contributor

@benbur98 benbur98 commented Mar 3, 2023

Fix Issue #1191

I have created a new card based largely from @saxel fan card. This has been completely re-based to follow the modern format from the Light Card. I feel this card is now ready to be a base card and not a custom-card.

I believe this should Close and Replace PR #134.

@benbur98
Copy link
Contributor Author

benbur98 commented Mar 3, 2023

I've also added a fix for Issue #1188

@benbur98 benbur98 mentioned this pull request Mar 3, 2023
4 tasks
@wokkeltje13
Copy link
Contributor

wokkeltje13 commented Mar 4, 2023

3 remarks:

  • I can't get the blue color
    image
  • oscillate button does not work
    image
  • after sliding to 0 and then enable the fan again, the slider remains on 0
    image

My yaml code (formatting seems to be broken here on github even when pasted as code)

  • type: "custom:button-card"
    template: card_fan
    entity: fan.ventilator_bureau
    variables:
    ulm_card_fan_name: Ventilator
    ulm_card_fan_enable_slider: true
    ulm_card_fan_enable_color: "blue"
    ulm_card_fan_force_background_color: true
    ulm_card_fan_enable_collapse: true
    ulm_card_fan_enable_button: true
    ulm_card_fan_button_icon: "mdi:rotate-3d-variant"
    ulm_card_fan_button_service: "fan.oscillate"

thanks already

@wokkeltje13
Copy link
Contributor

Maybe a 4th remark, clicking on the button icon should toggle the fan on/off

@benbur98
Copy link
Contributor Author

benbur98 commented Mar 4, 2023

hi @wokkeltje13 - really appreciate you're feedback on this.
The Color not showing is because I have named the variable: "ulm_card_fan_color" and not "ulm_card_fan_enable_color" - good spot, I'll update the documentation.
I've fixed the oscillation by hardcoding this, the service needs some specific service data so currently I can't work out a good way to make this button customisable.
For me clicking on the button does toggle the fan - I'm not too sure what you mean there?
I also cannot re-create your issue with the slider....
I'll keep looking

Copy link
Contributor

@wokkeltje13 wokkeltje13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 97 still contains the old var name in the exemple

@wokkeltje13
Copy link
Contributor

The slider issue seems to be gone, can't reproduce anymore.

  • Color is OK
  • Oscillate is still not working
    image
  • Clicking still investigation if it has something to do with custom actions, but everywhere I click, the details open instead off toggle

@wokkeltje13
Copy link
Contributor

Togle is working after adding fan to my custom actions
image

@wokkeltje13
Copy link
Contributor

Fixed oscillating button by adding extra var

oscillate_attribute: "oscillate"

and by changing the code to

              oscillating: "[[[ return !entity.attributes[variables.oscillate_attribute] ]]]"

1 issue still open, the button does not toggle color according to oscillating state

var temp = Math.round(entity.attributes[variables.ulm_card_fan_temp_attribute]);
let temp_str = ' • ' + (temp ? temp : '0') + '°C';
} else {
let temp_str = ''
}
if (variables.ulm_card_fan_slider_hum_attribute != False) {
if (variables.ulm_card_fan_slider_hum_attribute != false) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should probably be null or empty checks. The attributes are strings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have fixed this - however moving forwards I am personally focussing on the new card_fan and leaving the saxel fan behind.

@@ -78,13 +78,13 @@ custom_card_saxel_fan_common:
label: |-
[[[
if (entity.state != 'unavailable') {
if (variables.ulm_card_fan_slider_temp_attribute != False) {
if (variables.ulm_card_fan_slider_temp_attribute != false) {
var temp = Math.round(entity.attributes[variables.ulm_card_fan_temp_attribute]);
let temp_str = ' • ' + (temp ? temp : '0') + '°C';
} else {
let temp_str = ''

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this and hum_str should be defined outside the if scope

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have fixed this - however moving forwards I am personally focussing on the new card_fan and leaving the saxel fan behind.

@benbur98
Copy link
Contributor Author

benbur98 commented Mar 6, 2023

@wokkeltje13 > 1 issue still open, the button does not toggle color according to oscillating state

I have copied across the code from the old Saxel Fan for this button color, won't be able to test for a few days now but feel free to test yourself if you can :)

@wokkeltje13
Copy link
Contributor

The oscillate button is working now, but the color is still not changing when toggle.
tnx already

@wokkeltje13
Copy link
Contributor

I removed a part of the code and switched te colors and it seems to be working now.

The last part of card_fan.yaml I use now is:

      button:
        card:
          type: "custom:button-card"
          template:
            - "widget_icon"
          icon: "[[[ return variables.ulm_card_fan_button_icon ]]]"
          entity: "[[[ return entity.entity_id ]]]"
          tap_action:
            action: "call-service"
            service: "[[[ return variables.ulm_card_fan_button_service ]]]"
            service_data:
              entity_id: "[[[ return entity.entity_id ]]]"
              oscillating: "[[[ return !entity.attributes[variables.ulm_card_fan_oscillate_attribute] ]]]"
          state:
            - operator: "template"
              value: "[[[ return entity.state === 'on' && entity.attributes[variables.ulm_card_fan_oscillate_attribute]; ]]]"
              styles:
                card:
                  - background-color: "rgba(61, 90, 254, 1)"
                icon:
                  - color: "rgba(250, 250, 250, 1)"
                label:
                  - color: "rgba(250, 250, 250, 1)"
                name:
                  - color: "rgba(250, 250, 250, 1)"
                img_cell:
                  - background-color: "rgba(250, 250, 250, 0.2)"
            - operator: "template"
              value: "[[[ return entity.state === 'on' && !entity.attributes[variables.ulm_card_fan_oscillate_attribute]; ]]]"
              styles:
                card:
                  - background-color: "rgba(250, 250, 250, 1)"
                icon:
                  - color: "rgba(61, 90, 254, 1)"
                label:
                  - color: "rgba(250, 250, 250, 1)"
                name:
                  - color: "rgba(250, 250, 250, 1)"
                img_cell:
                  - background-color: "rgba(250, 250, 250, 0.2)"

@benbur98
Copy link
Contributor Author

benbur98 commented Mar 7, 2023

Thanks @wokkeltje13 - saved me some time! Looks like I left in some code from the light card that was taking over...

In general, I'm still not too pleased with how un-adaptable this button is (both in services and color), but I can continue to work on it over time... for now we have a good baseline card to go off at least.

@wokkeltje13
Copy link
Contributor

tnx, seems to be working as expected

wokkeltje13
wokkeltje13 previously approved these changes Mar 8, 2023
Copy link
Contributor

@wokkeltje13 wokkeltje13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can approve the new fan card and the changes to the cover card. No comment on the saxel card that is EOL with the new fan card

@basbruss basbruss mentioned this pull request Mar 8, 2023
3 tasks
@basbruss
Copy link
Collaborator

basbruss commented Mar 9, 2023

@benbur98 I have updated the color logic to be more inline with the example pictures

@basbruss basbruss merged commit 1371712 into UI-Lovelace-Minimalist:release Mar 10, 2023
@basbruss basbruss linked an issue Mar 10, 2023 that may be closed by this pull request
@benbur98 benbur98 deleted the card_fan branch March 10, 2023 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Since the update to 1.2.0 Custom-card "Fan" does not display
4 participants