dermotduffy / frigate-hass-card

A Lovelace card for Frigate in Home Assistant
MIT License
473 stars 52 forks source link

Auto config update of `hide` property results in invalid config #1453

Open felipecrs opened 2 weeks ago

felipecrs commented 2 weeks ago

Hi, I'd just like to report an issue with the automatic upgrade (from older dev branch to latest dev branch).

https://github.com/dermotduffy/frigate-hass-card/assets/29582865/ac3443c5-cd34-400f-bd36-e49368288346

card-31366e59.js:525  FRIGATE-HASS-CARD  Version 5.2.0 
create-element-base.ts:189 card custom:frigate-card Error: Configuração inválida: [
 "cameras[1] -> capabilities -> disable_except"
]
    at ck.setConfig (card-31366e59.js:88:31027)
    at lT.setConfig (card-31366e59.js:525:2491)
    at r (create-element-base.ts:104:11)
    at create-element-base.ts:118:12
    at h (create-element-base.ts:222:12)
    at c (create-element-base.ts:179:12)
    at f (create-card-element.ts:104:3)
    at n.value (hui-stack-card.ts:114:21)
    at hui-stack-card.ts:52:28
    at Array.map (<anonymous>)

Previous config

type: custom:frigate-card
cameras:
  - camera_entity: camera.rua
    dependencies:
      cameras:
        - rua_hd
    live_provider: go2rtc
    go2rtc:
      modes:
        - webrtc
  - camera_entity: camera.rua
    go2rtc:
      stream: rua_hd
    title: Rua (HD)
    id: rua_hd
    hide: true
    live_provider: go2rtc
dimensions:
  aspect_ratio_mode: static
  aspect_ratio: '89:100'
live:
  draggable: true
  show_image_during_load: true
  controls:
    builtin: false
    title:
      mode: none
    next_previous:
      style: none
    ptz:
      hide_zoom: true
      position: bottom-left
      actions_home:
        tap_action:
          action: call-service
          service: frigate.ptz
          data:
            entity_id: camera.rua
            action: preset
            argument: '1'
      actions_left:
        start_tap_action:
          action: call-service
          service: frigate.ptz
          data:
            entity_id: camera.rua
            action: move
            argument: right
        end_tap_action:
          action: call-service
          service: frigate.ptz
          data:
            entity_id: camera.rua
            action: stop
      actions_right:
        start_tap_action:
          action: call-service
          service: frigate.ptz
          data:
            entity_id: camera.rua
            action: move
            argument: left
        end_tap_action:
          action: call-service
          service: frigate.ptz
          data:
            entity_id: camera.rua
            action: stop
  microphone:
    always_connected: false
menu:
  style: outside
  buttons:
    frigate:
      enabled: false
    cameras:
      alignment: opposing
      enabled: false
    snapshots:
      enabled: false
    mute:
      enabled: true
      priority: 49
    substreams:
      icon: mdi:high-definition
      alignment: opposing
    timeline:
      enabled: false
    download:
      enabled: false
    microphone:
      enabled: true
      type: toggle
      priority: 48
image:
  refresh_seconds: 1
  zoomable: true

Auto-upgraded one

type: custom:frigate-card
cameras:
  - camera_entity: camera.rua
    dependencies:
      cameras:
        - rua_hd
    live_provider: go2rtc
    go2rtc:
      modes:
        - webrtc
  - camera_entity: camera.rua
    go2rtc:
      stream: rua_hd
    title: Rua (HD)
    id: rua_hd
    live_provider: go2rtc
    capabilities:
      disable_except: substream
dimensions:
  aspect_ratio_mode: static
  aspect_ratio: '89:100'
live:
  draggable: true
  show_image_during_load: true
  controls:
    builtin: false
    title:
      mode: none
    next_previous:
      style: none
    ptz:
      hide_zoom: true
      position: bottom-left
      actions_home:
        tap_action:
          action: call-service
          service: frigate.ptz
          data:
            entity_id: camera.rua
            action: preset
            argument: '1'
      actions_left:
        start_tap_action:
          action: call-service
          service: frigate.ptz
          data:
            entity_id: camera.rua
            action: move
            argument: right
        end_tap_action:
          action: call-service
          service: frigate.ptz
          data:
            entity_id: camera.rua
            action: stop
      actions_right:
        start_tap_action:
          action: call-service
          service: frigate.ptz
          data:
            entity_id: camera.rua
            action: move
            argument: left
        end_tap_action:
          action: call-service
          service: frigate.ptz
          data:
            entity_id: camera.rua
            action: stop
  microphone:
    always_connected: false
menu:
  style: outside
  buttons:
    frigate:
      enabled: false
    cameras:
      alignment: opposing
      enabled: false
    snapshots:
      enabled: false
    mute:
      enabled: true
      priority: 49
    substreams:
      icon: mdi:high-definition
      alignment: opposing
    timeline:
      enabled: false
    download:
      enabled: false
    microphone:
      enabled: true
      type: toggle
      priority: 48
image:
  refresh_seconds: 1
  zoomable: true
dermotduffy commented 1 week ago

disable_except: substream

Should be an array. Thanks!

dermotduffy commented 1 week ago

Additionally, whilst there is full unittest coverage of upgrade code, the test is checking that the end result of the conversion is what is expected. In this case, the error was both in the code and the test that was checking the code. It should also check that that end result actually parses as a valid config for the card ;-)