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

turn led on #6

Closed
eerison opened this issue Jul 29, 2023 · 42 comments
Closed

turn led on #6

eerison opened this issue Jul 29, 2023 · 42 comments

Comments

@eerison
Copy link
Contributor

eerison commented Jul 29, 2023

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

@dbuezas
Copy link
Owner

dbuezas commented Jul 29, 2023

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
Copy link
Contributor Author

eerison commented Jul 29, 2023

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

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

@dbuezas
Copy link
Owner

dbuezas commented Jul 29, 2023

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

@eerison
Copy link
Contributor Author

eerison commented Jul 29, 2023

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
Copy link
Owner

dbuezas commented Jul 29, 2023

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

  • I see that you are in Germany so you may have a fritzbox. With it you can go to 192.168.178.1/#cap and capture all the traffic (in my case I press start on AP2 (2.4 GHz, ath0) - Interface 0

  • With https://github.com/NeiroNx/python-dvr#investigate-more-settings you can check what settings are changing from your pc (this shows a change in {"root['WhiteLight']['WorkMode']": {'new_value': 'Close', 'old_value': 'Auto'}}, but setting it via set_info doesn't have any effect on lights

  • I just realised that the XMEye pro app for android does have working controls for the lights, but I see no jsons in the traffic, only binary messages (this is how i reversed engineered discovery for go2rtc so it can definitely be done for light)

@eerison eerison changed the title turn lead on turn led on Jul 30, 2023
@eerison
Copy link
Contributor Author

eerison commented Aug 2, 2023

Hey @dbuezas

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

Questions

  • You mentioned about this repository -> https://github.com/NeiroNx/python-dvr#investigate-more-settings , why? do you use this lib in your code, or is there other reason for you mentioned it?
  • {"root['WhiteLight']['WorkMode']": {'new_value': 'Close', 'old_value': 'Auto'}}, but setting it via set_info, maybe change this in config should work, where/how can I test it?

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

@dbuezas
Copy link
Owner

dbuezas commented Aug 2, 2023

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
Copy link
Contributor Author

eerison commented Aug 2, 2023

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
Copy link
Owner

dbuezas commented Aug 2, 2023

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

@eerison
Copy link
Contributor Author

eerison commented Aug 3, 2023

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
Copy link
Contributor Author

eerison commented Aug 3, 2023

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
Copy link
Owner

dbuezas commented Aug 3, 2023

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
Copy link
Contributor Author

eerison commented Aug 3, 2023

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

@dbuezas
Copy link
Owner

dbuezas commented Aug 3, 2023

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
Copy link
Owner

dbuezas commented Aug 3, 2023

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
Copy link
Contributor Author

eerison commented Aug 4, 2023

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

@dbuezas
Copy link
Owner

dbuezas commented Aug 4, 2023

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
Copy link
Contributor Author

eerison commented Aug 4, 2023

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
Copy link
Owner

dbuezas commented Aug 4, 2023

did you remove and readd your cameras?

@eerison
Copy link
Contributor Author

eerison commented Aug 4, 2023

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
Copy link
Owner

dbuezas commented Aug 4, 2023

Removing the cameras from this integration is enough :)

@dbuezas
Copy link
Owner

dbuezas commented Aug 4, 2023

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

@eerison
Copy link
Contributor Author

eerison commented Aug 4, 2023

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
Copy link
Owner

dbuezas commented Aug 4, 2023

Remove the devices from the integration instead

@dbuezas
Copy link
Owner

dbuezas commented Aug 4, 2023

And then restart for good measure

@eerison
Copy link
Contributor Author

eerison commented Aug 4, 2023

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
Copy link
Contributor Author

eerison commented Aug 4, 2023

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
Copy link
Owner

dbuezas commented Aug 4, 2023

Oh, i mean mac address.

  • In master i am using the hostname/ipaddress (which is bad because these may change),
  • Then I switched to the serial number of the camera (which is ok, but it doesn't let HA know that it is the same device as e.g your router or onvif integration detected)
  • Finally, I found out how to use the MAC address instead, which is perfect.

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
Copy link
Contributor Author

eerison commented Aug 4, 2023

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
Copy link
Contributor Author

eerison commented Aug 4, 2023

config/devices/dashboard

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

@dbuezas
Copy link
Owner

dbuezas commented Aug 4, 2023

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
Copy link
Contributor Author

eerison commented Aug 4, 2023

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
Copy link
Contributor Author

eerison commented Aug 4, 2023

Hey @dbuezas it worked from HA 🥳

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

@eerison
Copy link
Contributor Author

eerison commented Aug 4, 2023

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
Copy link
Contributor Author

eerison commented Aug 4, 2023

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
Copy link
Owner

dbuezas commented Aug 4, 2023

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
Copy link
Contributor Author

eerison commented Aug 5, 2023

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
Copy link
Owner

dbuezas commented Aug 5, 2023

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
Copy link
Owner

dbuezas commented Aug 5, 2023

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
Copy link
Contributor Author

eerison commented Aug 5, 2023

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
Copy link
Owner

dbuezas commented Aug 5, 2023

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

@dbuezas
Copy link
Owner

dbuezas commented Aug 5, 2023

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)

@dbuezas dbuezas closed this as completed Aug 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants