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

Digital zoom controls (via css) #482

Closed
dbuezas opened this issue May 1, 2023 · 5 comments
Closed

Digital zoom controls (via css) #482

dbuezas opened this issue May 1, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@dbuezas
Copy link
Contributor

dbuezas commented May 1, 2023

I have been wanting to have a "fake"/digital zoom for my cameras for a while. It would be a really cool feature if this card could do that (maybe even full fake ptz).

But in the meanwhile, here's a way to add it via yaml. It even works in full screen :)

Digital zoom in the card

Kapture 2023-05-01 at 22 22 44

Instructions

1. install https://github.com/thomasloven/lovelace-card-mod

2. Create a number helper from Open your Home Assistant instance and show your helper entities.

image

3. Modify the yaml of your webrtc-camera like this

type: custom:webrtc-camera
url: my_camera
card_mod:
  style: |
    ha-card .player {
      transition: transform 200ms;
      transform: scale({{2**(states('input_number.zoom')|float-1)}});
    }
shortcuts:
  services:
    - name: Zoom in
      icon: mdi:magnify-plus
      service: input_number.increment
      service_data:
        entity_id: input_number.zoom
    - name: Zoom out
      icon: mdi:magnify-minus
      service: input_number.decrement
      service_data:
        entity_id: input_number.zoom

(of course you can use the same input_number for multiple cameras)

@dbuezas
Copy link
Contributor Author

dbuezas commented May 2, 2023

This variation of the css is less elegant (zooms to top left instead of center), but it allows to scroll to any portion of the screen later.
May be useful for cameras without ptz

Kapture 2023-05-02 at 22 58 49

card_mod:
  style: |
    ha-card .player{
        overflow: auto;
    }
    ha-card .player video{
      transition: transform 200ms;
      transform: scale({{2**(states('input_number.zoom')|float-1)}});
      transform-origin: top left;
    }

@dbuezas
Copy link
Contributor Author

dbuezas commented May 18, 2023

I'm considering making a PR with a proper implementation of this. @AlexxIT If I do it cleanly and put it behind a config, and code touch support is googd, would you consider taking a PR?

@AlexxIT
Copy link
Owner

AlexxIT commented May 19, 2023

If your PR won't require helper entities and other custom cards - it will be good PR.

@dbuezas
Copy link
Contributor Author

dbuezas commented May 20, 2023

I have the first prototype, it feels really nice.
Kapture 2023-05-20 at 23 37 34
It has support for both mouse and touch (exactly the same zoom/pan behaviour as google maps) and can even persist the zoom options between reloads. It is also configurable (disable mouse and each touch interaction and persistance)

The PR will be coming soon. It's ~200 lines in a separate file and I'm only missing handling transitions to full screen correctly.

@dbuezas
Copy link
Contributor Author

dbuezas commented May 21, 2023

PR: #491

@AlexxIT AlexxIT added the enhancement New feature or request label Jun 16, 2023
@dbuezas dbuezas closed this as completed Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants