nspanel-lovelace-ui icon indicating copy to clipboard operation
nspanel-lovelace-ui copied to clipboard

[Feature Request] Alarm Control as cardEntities or cardGrid

Open WhistleMaster opened this issue 1 year ago • 8 comments

Hi !

Thanks for the great work on that project, it's working really well !

FEATURE DESCRIPTION

It would be a nice feature to be able to display an alarm control in a cardEntities or a cardGrid view, and clicking on it would display the cardAlarm as a popup. More or less as displaying a cover entity and when clicking on it, you have the position and so on.

ADDITIONAL CONTEXT

N/A

PANEL / FIRMWARE VERION

EU

WhistleMaster avatar Aug 12 '22 14:08 WhistleMaster

there is already a feature request for an alarm clock #378

joBr99 avatar Aug 12 '22 22:08 joBr99

I think there is a misunderstanding, I talking about a security alarm, not an alarm clock 😅

WhistleMaster avatar Aug 13 '22 04:08 WhistleMaster

What I would like to achieve is, as an example:

card-entities

    cards:
      - type: cardEntities
        title: Test Entities Card
        entities:
          - entity: light.bed_light
          - entity: switch.decorative_lights
          - entity: cover.hall_window
          - entity: alarm_control_panel.alarmo

or:

card-grid

    cards:
      - type: cardGrid
        title: Test Grid Card
        entities:
          - entity: alarm_control_panel.alarmo
          - entity: switch.decorative_lights
          - entity: sensor.outside_temperature
            name: Outside Temp
          - entity: sensor.carbon_monoxide
          - entity: light.entrance_color_white_lights
            name: Entrance
          - entity: light.office_rgbw_lights
            name: Office RGBW
            icon: mdi:office-building

And clicking on the entity would popup the cardAlarm: card-alarm

WhistleMaster avatar Aug 13 '22 05:08 WhistleMaster

It should be possible to configure a navigate item to the card and override the staus with the alarm entity

joBr99 avatar Aug 13 '22 07:08 joBr99

Sure !

For the display in cardEntities and cardGrid, I've had a look at the code of pages.py and added before L260 the following "quick&dirty" code and it's displaying fine the Alarm control:

if entityType == "alarm_control_panel":
    if entity.state == "disarmed":
      icon_color = rgb_dec565([13,160,53])
      icon_id = get_icon_id("shield-off")
    if entity.state == "armed_home":
      icon_color = rgb_dec565([223,76,30])
      icon_id = get_icon_id("shield-home")
    if entity.state == "armed_away":
      icon_color = rgb_dec565([223,76,30])
      icon_id = get_icon_id("shield-lock")
    if entity.state == "armed_night":
      icon_color = rgb_dec565([223,76,30])
      icon_id = get_icon_id("weather-night")
    if entity.state == "armed_vacation":
      icon_color = rgb_dec565([223,76,30])
      icon_id = get_icon_id("shield-airplane")
    text = get_translation(self._locale, f"frontend.state_badge.alarm_control_panel.{entity.state}")
    return f"~text~{entityId}~{icon_id}~{icon_color}~{name}~{text}"

I'm just now missing the way to actually push on the icon to navigate to the cardAlarm.

WhistleMaster avatar Aug 13 '22 15:08 WhistleMaster

I will add states and icons for the alarm entities. (maybe also with an automatic link to an card alarm, have to see) However it should be possible to do all of this in the configuration without the need of editing code.

joBr99 avatar Aug 13 '22 18:08 joBr99

Oh I see ! I've made a quick PR #400 already, feel free to delete it then if it's not what you had in mind 😃

WhistleMaster avatar Aug 13 '22 18:08 WhistleMaster

I will review it and update it if needed

joBr99 avatar Aug 13 '22 18:08 joBr99

Adding an example to navigate to a CardAlarm from the alarm panel entity:

cards:
  - type: cardGrid
    title: Example
    entities:
      - entity: navigate.cardAlarm_myAlarm
        status: alarm_control_panel.my_alarm
        name: My Alarm
hiddenCards:
  - type: cardAlarm
    title: My Alarm
    entity: alarm_control_panel.my_alarm
    key: myAlarm

WhistleMaster avatar Aug 24 '22 16:08 WhistleMaster