Lovelace: Versatile Swiss Army Knife Custom Card

Please share some teaser :smiley:

After updating to v2.5.1-dev.2, I copied everything in the following directory in my lovelace directory.

Be careful not to lose your templates.

Here is a teaser…

3 Likes

still the same error:

It has something to do with JS? Im no programmer. I can alter code but not create a lot myself. Can anyone shine another light on this error?

  - type: 'custom:swiss-army-knife-card'
    view_layout:
        grid-area: b4
    entities:
      - entity: sensor.buiten_temperatuur_temperature
        name: 'PM2.5'
        area: 'Study'
        icon: mdi:dots-circle
    layout:
      template:
        name: sak_layout_fce2_awair2a
        variables:
          - sak_layout_awair_chart_type: line
          - sak_layout_awair_background_icon_disabled: false
          - sak_layout_awair_sensor_colorstop_v1: sak_colorstops_awair_pm25_v1
          - sak_layout_awair_sensor_colorstop_v2: sak_colorstops_awair_pm25_v2
          - sak_layout_awair_sensor_scale_max: 100

Alright!!! Looks good! thanks

Sorry, i’ve absolutely no idea for your issue… the code is OK.

started HA in a new (edge) browser and here no issues with the error.
Cleared the cache in my brave browser along with some cookies and now it shows the card as it should. Problem solved!

1 Like

Another question:

I know how I can show or hide individual tools by e.g. “display: none/initial” at an on or off connected state.

Is it also possible to do this with an entire toolset so I have to code it once just for the toolset instead of connecting each individual tool to a state?

Someone I know, managed to make the Swiss Amy Knife cards work following the problem i.setConfig is not a function. He did the following steps and it works for him. Is it possible for peoples who have this problem to take a test?

Steps:

I have just taken over everything from the installation of the dashboard that uses Swiss-Army-Knife, and I was able to make it work in a repeatable way. This involves a few manual steps since the installation of Swiss-Army-Knife is broken. The process assumes that HACS is installed and configured, and that Lovelace is used in more storage.

Installation of Swiss Army Knife custom card from HACS

Ensure that the Javascript module /hacsfiles/swiss-army-knife-card/swiss-army-knife-card.js is loaded into the environment

Clone the git repo of swiss-army-knife to a suitable place to copy files

According to the SwissArmyKnife doc, step 2A, copy the sak_templates folder of the git repo (ha-config/lovelace) into your lovelace folder

I didn’t do step 2B of the SwissArmyKnife doc

In the SwissArmyKnife doc, step 2C, add the following configuration in the configuration.yaml file:


http:
  cors_allowed_origins:
    - https://unpkg.com
    - https://unpkg.com/lit-html@1/directives/style-map.js?module
    - https://unpkg.com/lit-html@1/directives/if-defined?module
    - https://unpkg.com/lit-html@%5E1.0.0?module
    - https://unpkg.com/lit-html@1/directives/style-map.js?module

Hey guys, don’t find a solution.
I try to make it possible in the best way the next step of the sparkling is pulsing while loading.
Not sure about the animation of the sparkline steps. Don’t like to use template and make single rectex for this.

If not possible try to animate by a second entity like charge or discharge and make the foreground or background of the sparkline pulsing.

I wil try to help but do not know quite what you are trying to accomplish…Could you explain it more in detail?

Hey tuupos thanks for reply. Was ill sorry for delay. On charging pulse animation the blue one (next step)
On discharge pulsing the violet one (actual step)

Hello all, I was wondering if anyone has the same issue as I. I don’t know exactly when but I noticed last Sunday that the 5 day weather forcast and SAK is not working any more. When I disable all the entities on the card (it is a part of the example from Mars) I have a empty card, as expected. When I enable all the entities the card disappears (not visable). I found out that when I disable the use
svg part (images in the circle) the card stay’s visable.


picture_002
picture_003

Normally I use buienradar (Dutch provider) and it worked until some time ago. I did a test with met.no with the same result. The funny part is that when I click double on these entities the information is shown. So seperatly things just works fine. First screenshot shows also a SAK card which is the first part of the example of Mars.

I’m still in the dark why. Just to be sure I did redownload SAK but it did not do the trick. Any else experianced this?

Hi,

Have you adapted your code with the new way to have the weather forecast? You must use the weather.get_forecasts service to get it since the Core 2024.4 update.

He ValMarDav,

No I did not. I will follow the link you send to enable it. Thanks for your assistant.

Ok, I checked the weather integration link you gave and I’m confused. No idea where the service weather.get_forcast is and how to adjust.

Started reading and followed the link weather category. After that opened buienradar. It does not mention anything about adding a service. It should be there. The only thing needs to be done according to the site is enable the by default disabled entites, this was already the case and it is working for I can see information when I open the entity.

Hi,

This discussion shows you how to use the new weather.get_forecasts service.

Hi ValMarDav,

Thank you for the links, I have two working entities. Did not change anything on the dashboard but the entities are poupated with information. After correction some typo errors I get this warning.

Screenshot_20240505_160356

I can repair it with the message that the repair was succesfull but when I reboot HA it comes back again.

Later I will change the entites on my dashbard - I’ll let you know what the results are.

Hi,

This is the old service, you must use the new one with an s at the end of the name.

weather.get_forecasts 

Here is an example of how to use the service to obtain forecasts. Day one of the forecasts.


template:
  # Obtenir les pévisions journalières

  - trigger:
      - platform: time_pattern
        hours: /1
    action:
      - service: weather.get_forecasts
        data:
          type: daily
        target:
          entity_id:
            - weather.forecast_shawinigan_sud
        response_variable: previsionsj1
    sensor:

      # Conditions
      
      - name: "def_previsions_condition_j1"
        unique_id: "def_previsions_condition_j1"
        state: "{{ previsionsj1['weather.forecast_shawinigan_sud'].forecast[1].condition }}"
        
      # Date et heure
      
      - name: "def_heure_date_j1"
        unique_id: "def_heure_date_j1"
        state: "{{ previsionsj1['weather.forecast_shawinigan_sud'].forecast[1].datetime }}"

      # precipitation probability

      - name: "def_previsions_precipitation_probability_j1"
        unique_id: "def_previsions_precipitation_probability_j1"
        unit_of_measurement: "%"
        state: "{{ previsionsj1['weather.forecast_shawinigan_sud'].forecast[1].precipitation_probability }}"        

      # Temperature

      - name: "def_previsions_temperature_j1"
        unique_id: "def_previsions_temperature_j1"
        unit_of_measurement: "°C"
        state: "{{ previsionsj1['weather.forecast_shawinigan_sud'].forecast[1].temperature }}"

      # Basse température

      - name: "def_previsions_templow_j1"
        unique_id: "def_previsions_templow_j1"
        unit_of_measurement: "°C"
        state: "{{ previsionsj1['weather.forecast_shawinigan_sud'].forecast[1].templow }}"

      # Precipitation

      - name: "def_previsions_precipitation_j1"
        unique_id: "def_previsions_precipitation_j1"
        unit_of_measurement: "mm"
        state: "{{ previsionsj1['weather.forecast_shawinigan_sud'].forecast[1].precipitation }}"

The code above you mentioned earlier does not have the s in the end so that’s why I did not add it. Now I did at the s in the end and then the entities are not loaded.

# Weather forcast
template:
  - trigger:
      - platform: time_pattern
        minutes: "*"
      - platform: homeassistant
        event: start
      - platform: event
        event_type: event_template_reloaded
    action:
      - service: weather.get_forecasts
        target:
          entity_id: weather.forecast_home
        data:
          type: hourly
        response_variable: hourly_forecast
      - service: weather.get_forecasts
        target:
          entity_id: weather.forecast_home
        data:
          type: daily
        response_variable: daily_forecast
    sensor:
      - name: "weather hourly"
        unique_id: home_hourly
        state: "{{ states('weather.forecast_home') }}"
        attributes:
          temperature: "{{ state_attr('weather.forecast_home', 'temperature') }}"
          dew_point: "{{ state_attr('weather.forecast_home', 'dew_point') }}"
          temperature_unit: "{{ state_attr('weather.forecast_home', 'temperature_unit') }}"
          humidity: "{{ state_attr('weather.forecast_home', 'humidity') }}"
          cloud_coverage: "{{ state_attr('weather.forecast_home', 'cloud_coverage') }}"
          pressure: "{{ state_attr('weather.forecast_home', 'pressure') }}"
          pressure_unit: "{{ state_attr('weather.forecast_home', 'pressure_unit') }}"
          wind_bearing: "{{ state_attr('weather.forecast_home', 'wind_bearing') }}"
          wind_gust_speed: "{{ state_attr('weather.forecast_home', 'wind_gust_speed') }}"
          wind_speed: "{{ state_attr('weather.forecast_home', 'wind_speed') }}"
          wind_speed_unit: "{{ state_attr('weather.forecast_home', 'wind_speed_unit') }}"
          visibility: "{{ state_attr('weather.forecast_home', 'visibility') }}"
          visibility_unit: "{{ state_attr('weather.forecast_home', 'visibility_unit') }}"
          precipitation: "{{ state_attr('weather.forecast_home', 'precipitation') }}"
          precipitation_unit: "{{ state_attr('weather.forecast_home', 'precipitation_unit') }}"
          forecast: "{{ hourly_forecast.forecast[:5] }}"

      - name: "weather_daily"
        unique_id: home_daily
        state: "{{ states('weather.forecast_home') }}"
        attributes:
          temperature: "{{ state_attr('weather.forecast_home', 'temperature') }}"
          dew_point: "{{ state_attr('weather.forecast_home', 'dew_point') }}"
          temperature_unit: "{{ state_attr('weather.forecast_home', 'temperature_unit') }}"
          humidity: "{{ state_attr('weather.forecast_home', 'humidity') }}"
          cloud_coverage: "{{ state_attr('weather.forecast_home', 'cloud_coverage') }}"
          pressure: "{{ state_attr('weather.forecast_home', 'pressure') }}"
          pressure_unit: "{{ state_attr('weather.forecast_home', 'pressure_unit') }}"
          wind_bearing: "{{ state_attr('weather.forecast_home', 'wind_bearing') }}"
          wind_gust_speed: "{{ state_attr('weather.forecast_home', 'wind_gust_speed') }}"
          wind_speed: "{{ state_attr('weather.forecast_home', 'wind_speed') }}"
          wind_speed_unit: "{{ state_attr('weather.forecast_home', 'wind_speed_unit') }}"
          visibility: "{{ state_attr('weather.forecast_home', 'visibility') }}"
          visibility_unit: "{{ state_attr('weather.forecast_home', 'visibility_unit') }}"
          precipitation: "{{ state_attr('weather.forecast_home', 'precipitation') }}"
          precipitation_unit: "{{ state_attr('weather.forecast_home', 'precipitation_unit') }}"
          forecast: "{{ daily_forecast.forecast[:5] }}"

Must be another typo somewhere although I don’t see it. The entity_id is correct, checked that one.

Changed the minutes: “*” to hours: /1 does no change anything

Hello ValMarDav,

Don’t know why your suggestion is deleted, it was the solution. There was one small error in the “deleted” code what even a noob like me could spot.

The ’ after home was the wrong one. Thanks for your patience and assistant.