dbuezas / icsee-ptz

44 stars 7 forks source link

turn led on #6

Closed eerison closed 11 months ago

eerison commented 11 months ago

Hello do you have any idea how to turn led on?

dbuezas commented 11 months ago

Hi, you can obviously do it from icsee so I assume you mean from within this integration. I haven't implemented this, but I'll take a quick look at what commands icsee is sending, maybe it is easy to add a switch

eerison commented 11 months ago

Yep I mean in the integration, how do you debug it?

Edit 1: do you intercept the request from app to cam?

dbuezas commented 11 months ago

Yes, I have a router that can record the network traffic, then I can look at it through wireshark.

Anyway, here's what I found:

TL;DR: didn't manage to get it to work

eerison commented 11 months ago

Yes, I have a router that can record the network traffic, then I can look at it through wireshark.

Anyway, here's what I found:

  • The ICSee app is setting this via some binary protocol, not the standard json one.
  • The VMS app from XMEye (which uses json) doesn't seem to actually have a working function to turn the white light on/off
  • Looking directly at the camera configs, i see that Camera/WhiteLight/WorkMode switch between close, auto and intelligent, but changing those configs directly doesn't seem to affect the lamp.

TL;DR: didn't manage to get it to work

Thank you for your reply, maybe I could investigate a bit more how to do this, if I find something I open a pr ;)

dbuezas commented 11 months ago

That would be awesome :) Here are some more tips:

eerison commented 11 months ago

Hey @dbuezas

I was checking the communication between ICsee app -> camera, and as you said, there is binary interaction only :'(

Questions

Note: I don't know if you tested it in the dark, because this functionality just work without lights, even using ICSee app.

dbuezas commented 11 months ago

Hi, yes I tested it in the dark, no luck.

I mentioned that repo because that's what this integration uses internally, and because it has functions to get and set various configurations.

I started an issue in that repo about this topic, check it out: https://github.com/NeiroNx/python-dvr/issues/52

eerison commented 11 months ago

Thanks for the update, I didn't know you handle binary for some functionalities, I will follow the issue that you mentioned, and see if I can help somehow :D

dbuezas commented 11 months ago

I tried replicating the binary protocol, but i didn't succeed. It seems to be encrypted

eerison commented 11 months ago

When I was installing pip3 install dvrip, it was installing a old version 0.0.3, then I uninstall and installed again from master branch

pip3 install https://github.com/NeiroNx/python-dvr@master

and your code worked for me :D, Just for your information ;)

eerison commented 11 months ago

Hey @dbuezas Good news I found witch field is responsible for control this light!

it's Camera.Param.0.DayNightColor

and when I switch between those values I see the change in the app, I'm doing this

info = cam.get_info("Camera.Param")

# EO-IR Alert
info[0]['DayNightColor'] = '0x00000003'
# Full Color
info[0]['DayNightColor'] = '0x00000004'
# Infrared Night Vision
info[0]['DayNightColor'] = '0x00000005'

cam.set_info("Camera.Param", info)

The question is, how to integrate it with home assistant :D, do you have some example how you change settings from HA?

Edit 1: In my case I want to switch between Full Color (On) and Infrared Night Vision (Off)

dbuezas commented 11 months ago

Wow, really... I tried 0x0, 0x1 and 0x2 🤦

For Home Assistant, I'll add them to this integration. Did you also confirm that they turn the LED on/off?

eerison commented 11 months ago

Hey @dbuezas , Yep I tested, and It worked <3

dbuezas commented 11 months ago

Ok, I'll add that to the integration. I tested it in one of my cameras and it didn't work, but it is a weird camera anyway hehe

dbuezas commented 11 months ago

Experimental release with light control https://github.com/dbuezas/icsee-ptz/releases/tag/v3.0.1 (you'll need to re-add the cameras yet again, I changed unique ids to use the mac address)

eerison commented 11 months ago

Do you have some example to use in card? Do I need to add a new sensor?

dbuezas commented 11 months ago

You should have gotten a new entity for each camera:

image

Note that this is experimental, so something may change before this is out of beta

eerison commented 11 months ago

I got this issue

homeassistant    | 2023-08-04 06:30:15.863 ERROR (MainThread) [custom_components.icsee_ptz.switch] entry.data[CONF_SYSTEM_CAPABILITIES]
homeassistant    | 2023-08-04 06:30:15.869 ERROR (MainThread) [custom_components.icsee_ptz.switch] entry.data[CONF_SYSTEM_CAPABILITIES]["AlarmFunction"]
homeassistant    | --- Logging error ---
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/local/lib/python3.11/logging/handlers.py", line 1498, in emit
homeassistant    |     self.enqueue(self.prepare(record))
homeassistant    |                  ^^^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/usr/src/homeassistant/homeassistant/util/logging.py", line 44, in prepare
homeassistant    |     record = super().prepare(record)
homeassistant    |              ^^^^^^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/usr/local/lib/python3.11/logging/handlers.py", line 1480, in prepare
homeassistant    |     msg = self.format(record)
homeassistant    |           ^^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 953, in format
homeassistant    |     return fmt.format(record)
homeassistant    |            ^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 687, in format
homeassistant    |     record.message = record.getMessage()
homeassistant    |                      ^^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 377, in getMessage
homeassistant    |     msg = msg % self.args
homeassistant    |           ~~~~^~~~~~~~~~~
homeassistant    | TypeError: not all arguments converted during string formatting
homeassistant    | Call stack:
homeassistant    |   File "<frozen runpy>", line 198, in _run_module_as_main
homeassistant    |   File "<frozen runpy>", line 88, in _run_code
homeassistant    |   File "/usr/src/homeassistant/homeassistant/__main__.py", line 226, in <module>
homeassistant    |     sys.exit(main())
homeassistant    |   File "/usr/src/homeassistant/homeassistant/__main__.py", line 214, in main
homeassistant    |     exit_code = runner.run(runtime_conf)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/runner.py", line 179, in run
homeassistant    |     return loop.run_until_complete(setup_and_run_hass(runtime_config))
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/base_events.py", line 640, in run_until_complete
homeassistant    |     self.run_forever()
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/base_events.py", line 607, in run_forever
homeassistant    |     self._run_once()
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1922, in _run_once
homeassistant    |     handle._run()
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
homeassistant    |     self._context.run(self._callback, *self._args)
homeassistant    |   File "/config/custom_components/icsee_ptz/switch.py", line 33, in async_setup_entry
homeassistant    |     _LOGGER.error(
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 1518, in error
homeassistant    |     self._log(ERROR, msg, args, **kwargs)
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 1634, in _log
homeassistant    |     self.handle(record)
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 1644, in handle
homeassistant    |     self.callHandlers(record)
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 1706, in callHandlers
homeassistant    |     hdlr.handle(record)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/util/logging.py", line 62, in handle
homeassistant    |     self.emit(record)
homeassistant    | Message: 'entry.data[CONF_SYSTEM_CAPABILITIES]["AlarmFunction"]["MotionDetect"]'
homeassistant    | Arguments: (True,)
homeassistant    | 2023-08-04 06:30:15.884 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up icsee_ptz platform for binary_sensor
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 320, in _async_setup_platform
homeassistant    |     await asyncio.shield(task)
homeassistant    |   File "/config/custom_components/icsee_ptz/binary_sensor.py", line 49, in async_setup_entry
homeassistant    |     [
homeassistant    |   File "/config/custom_components/icsee_ptz/binary_sensor.py", line 50, in <listcomp>
homeassistant    |     Alarm(hass, entry, channel)
homeassistant    |   File "/config/custom_components/icsee_ptz/binary_sensor.py", line 62, in __init__
homeassistant    |     assert self._attr_unique_id  # set by ICSeeEntity
homeassistant    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant    | AssertionError
homeassistant    | 2023-08-04 06:30:15.901 ERROR (MainThread) [homeassistant.components.switch] Error while setting up icsee_ptz platform for switch
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 320, in _async_setup_platform
homeassistant    |     await asyncio.shield(task)
homeassistant    |   File "/config/custom_components/icsee_ptz/switch.py", line 39, in async_setup_entry
homeassistant    |     new_entities.append(AlarmSwitch(hass, entry, channel))
homeassistant    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/config/custom_components/icsee_ptz/switch.py", line 55, in __init__
homeassistant    |     assert self._attr_unique_id  # set by ICSeeEntity
homeassistant    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant    | AssertionError
homeassistant    | 2023-08-04 06:30:15.920 ERROR (MainThread) [homeassistant.components.select] Error while setting up icsee_ptz platform for select
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 320, in _async_setup_platform
homeassistant    |     await asyncio.shield(task)
homeassistant    |   File "/config/custom_components/icsee_ptz/select.py", line 24, in async_setup_entry
homeassistant    |     [
homeassistant    |   File "/config/custom_components/icsee_ptz/select.py", line 25, in <listcomp>
homeassistant    |     DayNightColorSelect(hass, entry, channel)
homeassistant    |   File "/config/custom_components/icsee_ptz/select.py", line 50, in __init__
homeassistant    |     assert self._attr_unique_id  # set by ICSeeEntity
homeassistant    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant    | AssertionError
homeassistant    | 2023-08-04 06:30:17.028 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback Entity.async_write_ha_state()
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
homeassistant    |     self._context.run(self._callback, *self._args)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 586, in async_write_ha_state
homeassistant    |     raise NoEntitySpecifiedError(
homeassistant    | homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity None
homeassistant    | 2023-08-04 06:30:17.040 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback Entity.async_write_ha_state()
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
homeassistant    |     self._context.run(self._callback, *self._args)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 586, in async_write_ha_state
homeassistant    |     raise NoEntitySpecifiedError(
homeassistant    | homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity None
homeassistant    | 2023-08-04 06:30:17.051 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback Entity.async_write_ha_state()
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
homeassistant    |     self._context.run(self._callback, *self._args)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 586, in async_write_ha_state
homeassistant    |     raise NoEntitySpecifiedError(
homeassistant    | homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity None

I'm using version 3.0.1

dbuezas commented 11 months ago

did you remove and readd your cameras?

eerison commented 11 months ago

I removed webRTC and ICSee integration from here: config/integrations/dashboard, and I added again, and I removed camera card from my dashboard also.

Am I missing something?

Screenshot from 2023-08-04 12-48-15

dbuezas commented 11 months ago

Removing the cameras from this integration is enough :)

dbuezas commented 11 months ago

I've changed the unique ids of things to mac addresses, so the old entities are missing data.

eerison commented 11 months ago

I removed from integration and HACS and I'm still getting an issue :'(

homeassistant    | 2023-08-04 08:12:09.028 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up icsee_ptz platform for binary_sensor
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 320, in _async_setup_platform
homeassistant    |     await asyncio.shield(task)
homeassistant    |   File "/config/custom_components/icsee_ptz/binary_sensor.py", line 49, in async_setup_entry
homeassistant    |     [
homeassistant    |   File "/config/custom_components/icsee_ptz/binary_sensor.py", line 50, in <listcomp>
homeassistant    |     Alarm(hass, entry, channel)
homeassistant    |   File "/config/custom_components/icsee_ptz/binary_sensor.py", line 62, in __init__
homeassistant    |     assert self._attr_unique_id  # set by ICSeeEntity
homeassistant    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant    | AssertionError
homeassistant    | 2023-08-04 08:12:09.147 ERROR (MainThread) [homeassistant.components.select] Error while setting up icsee_ptz platform for select
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 320, in _async_setup_platform
homeassistant    |     await asyncio.shield(task)
homeassistant    |   File "/config/custom_components/icsee_ptz/select.py", line 24, in async_setup_entry
homeassistant    |     [
homeassistant    |   File "/config/custom_components/icsee_ptz/select.py", line 25, in <listcomp>
homeassistant    |     DayNightColorSelect(hass, entry, channel)
homeassistant    |   File "/config/custom_components/icsee_ptz/select.py", line 50, in __init__
homeassistant    |     assert self._attr_unique_id  # set by ICSeeEntity
homeassistant    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant    | AssertionError
homeassistant    | 2023-08-04 08:12:09.193 ERROR (MainThread) [custom_components.icsee_ptz.switch] entry.data[CONF_SYSTEM_CAPABILITIES]
homeassistant    | 2023-08-04 08:12:09.198 ERROR (MainThread) [custom_components.icsee_ptz.switch] entry.data[CONF_SYSTEM_CAPABILITIES]["AlarmFunction"]
homeassistant    | --- Logging error ---
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/local/lib/python3.11/logging/handlers.py", line 1498, in emit
homeassistant    |     self.enqueue(self.prepare(record))
homeassistant    |                  ^^^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/usr/src/homeassistant/homeassistant/util/logging.py", line 44, in prepare
homeassistant    |     record = super().prepare(record)
homeassistant    |              ^^^^^^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/usr/local/lib/python3.11/logging/handlers.py", line 1480, in prepare
homeassistant    |     msg = self.format(record)
homeassistant    |           ^^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 953, in format
homeassistant    |     return fmt.format(record)
homeassistant    |            ^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 687, in format
homeassistant    |     record.message = record.getMessage()
homeassistant    |                      ^^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 377, in getMessage
homeassistant    |     msg = msg % self.args
homeassistant    |           ~~~~^~~~~~~~~~~
homeassistant    | TypeError: not all arguments converted during string formatting
homeassistant    | Call stack:
homeassistant    |   File "<frozen runpy>", line 198, in _run_module_as_main
homeassistant    |   File "<frozen runpy>", line 88, in _run_code
homeassistant    |   File "/usr/src/homeassistant/homeassistant/__main__.py", line 226, in <module>
homeassistant    |     sys.exit(main())
homeassistant    |   File "/usr/src/homeassistant/homeassistant/__main__.py", line 214, in main
homeassistant    |     exit_code = runner.run(runtime_conf)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/runner.py", line 179, in run
homeassistant    |     return loop.run_until_complete(setup_and_run_hass(runtime_config))
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/base_events.py", line 640, in run_until_complete
homeassistant    |     self.run_forever()
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/base_events.py", line 607, in run_forever
homeassistant    |     self._run_once()
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1922, in _run_once
homeassistant    |     handle._run()
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
homeassistant    |     self._context.run(self._callback, *self._args)
homeassistant    |   File "/config/custom_components/icsee_ptz/switch.py", line 33, in async_setup_entry
homeassistant    |     _LOGGER.error(
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 1518, in error
homeassistant    |     self._log(ERROR, msg, args, **kwargs)
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 1634, in _log
homeassistant    |     self.handle(record)
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 1644, in handle
homeassistant    |     self.callHandlers(record)
homeassistant    |   File "/usr/local/lib/python3.11/logging/__init__.py", line 1706, in callHandlers
homeassistant    |     hdlr.handle(record)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/util/logging.py", line 62, in handle
homeassistant    |     self.emit(record)
homeassistant    | Message: 'entry.data[CONF_SYSTEM_CAPABILITIES]["AlarmFunction"]["MotionDetect"]'
homeassistant    | Arguments: (True,)
homeassistant    | 2023-08-04 08:12:09.224 ERROR (MainThread) [homeassistant.components.switch] Error while setting up icsee_ptz platform for switch
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 320, in _async_setup_platform
homeassistant    |     await asyncio.shield(task)
homeassistant    |   File "/config/custom_components/icsee_ptz/switch.py", line 39, in async_setup_entry
homeassistant    |     new_entities.append(AlarmSwitch(hass, entry, channel))
homeassistant    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/config/custom_components/icsee_ptz/switch.py", line 55, in __init__
homeassistant    |     assert self._attr_unique_id  # set by ICSeeEntity
homeassistant    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant    | AssertionError
homeassistant    | 2023-08-04 08:12:10.367 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback Entity.async_write_ha_state()
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
homeassistant    |     self._context.run(self._callback, *self._args)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 586, in async_write_ha_state
homeassistant    |     raise NoEntitySpecifiedError(
homeassistant    | homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity None
homeassistant    | 2023-08-04 08:12:10.384 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback Entity.async_write_ha_state()
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
homeassistant    |     self._context.run(self._callback, *self._args)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 586, in async_write_ha_state
homeassistant    |     raise NoEntitySpecifiedError(
homeassistant    | homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity None
homeassistant    | 2023-08-04 08:12:10.397 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback Entity.async_write_ha_state()
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
homeassistant    |     self._context.run(self._callback, *self._args)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 586, in async_write_ha_state
homeassistant    |     raise NoEntitySpecifiedError(
homeassistant    | homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity None

But the strange thing is, that worked for you 🥲

dbuezas commented 11 months ago

Remove the devices from the integration instead

dbuezas commented 11 months ago

And then restart for good measure

eerison commented 11 months ago

Did you run your HA in docker? you said that you changed to mac, I don't know how you use this, but docker network is not in the same camera's network!

do you think it could be the issue? I removed restart, and I'm still facing the same issue :'(

eerison commented 11 months ago

You should have gotten a new entity for each camera:

image

Note that this is experimental, so something may change before this is out of beta

and I don't know where you found this controls, is it in HACS service?

dbuezas commented 11 months ago

Oh, i mean mac address.

Those controls are in the Device view. Go to http://homeassistant.local:8123/config/devices/dashboard or through the integration. It gathers all entities that belong to the same device (now identified via its mac address).

To control that you can use the the Select option service, e.g:

service: select.select_option
data:
  option: Color light
target:
  entity_id: select.antena_day_night_color
eerison commented 11 months ago

after I add the credentials here: image

Version 2.02

I could see 1 entity and 1 device, and no error in console

Screenshot from 2023-08-04 18-41-17

Version 3.0.1 I do not see any entity and device and I see the error above in console.

eerison commented 11 months ago

config/devices/dashboard

I just see this device in version 2, not in 3 Screenshot from 2023-08-04 18-47-43

dbuezas commented 11 months ago

Can you delete the camera (click on the three dormts right to "configure", then delete) and then add it again. What do you see?

eerison commented 11 months ago

as I was suspecting the issue was because my HA wasn't in the same camera's network, when I added container in the host network, it worked.

just to you have an idea how It is setup.

version: '3'

services:
  homeassistant:
    image: "ghcr.io/home-assistant/home-assistant:stable"
    container_name: homeassistant
    volumes:
      - ./config:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    privileged: true
    network_mode: host
    ports:
      - 8123:8123
    #networks:
    # - proxy
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=proxy"
      - "traefik.http.routers.homeassistant.rule=Host(`home.myhost-blabla.com`)"
      - "traefik.http.routers.homeassistant.entrypoints=websecure"
      - "traefik.http.services.homeassistant.loadbalancer.server.port=8123"
      - "traefik.http.routers.homeassistant.tls.certresolver=cloudflare"

networks:
  proxy:
    external: true

as you can see my HA was behind of traefik, and to access HA was possible just via proxy.

anyway the issue was network, I can see other way to handle just HA in different way.

now I can see the new configurations that you added, I will try to configure and let you know.

eerison commented 11 months ago

Hey @dbuezas it worked from HA 🥳

But do you have some example to add a button to switch between 2 values ?

eerison commented 11 months ago

In case you could provide some example, it gonna help me.

But this issue can be closed in ny opinion, I can handle lights from HA !

Thank you so much for your support

eerison commented 11 months ago

I was thinking...

Isn't it possible you keep the configuration as before and with Mac address? Or maybe by ip address 🤔?

Because I could make this work but with some shit workarounds 🥲

dbuezas commented 11 months ago

Now it is mac addresses, before it was serial number, and before just ip. I could go back to using serial numbers as unique ids, but pass the mac to identify the device. I still don't understand how this doesn't work in your setup 🤷 . Anyway, to switch between the two you can make a script that calls the select service.

eerison commented 11 months ago

Now it is mac addresses, before it was serial number, and before just ip. I could go back to using serial numbers as unique ids, but pass the mac to identify the device. I still don't understand how this doesn't work in your setup 🤷 . Anyway, to switch between the two you can make a script that calls the select service.

Probably for you get the mac into the network, you do some nmap to get the devices, but it works when the HA is in the same network as others devices.

As I'm using docker, it generates a sub network and nmap won't work.

It's my guess, because after add the container in the same network of "host", it worked.

After I add this line in my docker-compose.yaml

network_mode: host
dbuezas commented 11 months ago

Indeed! Why don't you have the cameras in the same subnet? I copied the procedure from other integrations, so this will cause you trouble with other devices too

dbuezas commented 11 months ago

I'll rephrase: is there any reason not to keep everything in the same subnet? Other integrations use the same procedure to grab the mac address, so they also expect this.

eerison commented 11 months ago

All services in my "raspberry" are running in docker, and all containers are using a docker network (named proxy), docker don't allow me to use network and network_mode together, then just for HA I need to keep outside of proxy network.

Definitely I fixed some issues, but created others 😅, but well probably there is some better solution for my side, I'm sure that someone else faced the same problem 😆, I just need to search a bit more.

dbuezas commented 11 months ago

I'll see if I can fall back to serial number if the mac address can't be resolved

dbuezas commented 11 months ago

Released in https://github.com/dbuezas/icsee-ptz/releases/tag/v3.0.2 (enable experimental entities in the CONFIGURE options of the integration to access LED controls)