Giter Site home page Giter Site logo

palazzem / ha-econnect-alarm Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 5.0 1.46 MB

Home Assistant integration that provides a full-fledged Alarm Panel to control your Elmo/IESS alarm systems.

License: BSD 3-Clause "New" or "Revised" License

Python 98.91% Shell 1.09%
alarm-system econnect home-assistant home-automation internet-of-things iot python elmo iess metronet

ha-econnect-alarm's Introduction

Home Assistant Elmo/IESS Integration

Linting Testing Coverage Status hacs_badge

This project is a Home Assistant integration for your Elmo/IESS Alarm connected to e-Connect cloud or Metronet.

Supported Systems

This integration supports Elmo/IESS alarm systems. The following systems are known to work:

Available functionalities

  • Configuration flow implemented to add login credentials and home and night areas
  • Arm and disarm the alarm based on sectors you have configured
  • Query the system and get the status of your sectors and inputs (e.g. doors, windows, etc.) and see if they are triggered or not
  • A service is available and you can configure automations via YAML or via UI
  • EconnectAlarm entity is available and you can use the AlarmPanel card to control it in lovelace

Alarm status

  • Arm Away: arms all areas
  • Disarm: disarm all areas
  • Arm Home: based on the configuration, arms given areas (optional)
  • Arm Night: based on the configuration, arms given areas (optional)

If you are curious about the project and want to know more, check out our Discord channel!

Installation

Download the Integration

  1. Create a new folder in your configuration folder (where the configuration.yaml lives) called custom_components
  2. Download the latest version into the custom_components folder so that the full path from your config folder is custom_components/econnect_metronet/
  3. Restart Home Assistant. If it's your only custom component you'll see a warning in your logs.
  4. Once Home Assistant is started, from the UI go to Configuration > Integrations > Add Integrations. Search for "Elmo/IESS Alarm". After selecting, dependencies will be downloaded and it could take up to a minute.

Setup

  • Username: is your username to access Elmo/IESS via web or app.
  • Password: is your password to access Elmo/IESS via web or app.
  • System: pick the brand of alarm system you are using.
  • Domain name: domain used to access your login page via web. If you access to https://connect.elmospa.com/vendor/, you must set the domain to vendor. In case you don't have a vendor defined, leave it to default.

Options

In the option page you can configure your alarm presets in case you want to fine-tune which sectors are armed. To proceed with the configuration, open the integration page and click on Elmo/IESS integration. Once the page is opened, you should see the following integration page:

To configure the integration, click on "Configure".

You can now define your presets:

  • Armed areas while at home: list areas you want to arm when you select Arm Home.
  • Armed areas at night (optional): list areas you want to arm when you select Arm Night.
  • Armed areas on vacation (optional): list areas you want to arm when you select Arm Vacation.

In case you don't define any sector for a given preset, no actions are taken when you use the preset from your alarm panel.

Automations

If you use automations, remember that in the payload you must send the code so that the system will be properly armed/disarmed.

YAML example:

service: alarm_control_panel.alarm_arm_away
target:
  entity_id: alarm_control_panel.<YOUR ALARM ENTITY ID>
data:
  code: !secret alarm_code  # (check how to use secrets if you are not familiar)

You can find <YOUR ALARM ENTITY ID> under Settings > Devices & Services > e-Connect/Metronet Alarm opening the list of entities and searching for Alarm Panel

UI example:

Apple Home integration (HomeKit)

If you want to integrate your alarm with the Apple Home to use Siri or automations, follow these steps:

  1. Add these entries inside configuration.yaml to let Home Assistant create a new HomeKit bridge with just the Alarm Panel exposed.
homekit:
  - name: HASS Bridge Alarm
    port: 21065
    filter:
      include_domains:
        - alarm_control_panel
    entity_config:
      alarm_control_panel.<YOUR ALARM ENTITY ID>:
        code: <PIN CODE>
  1. Please replace <PIN CODE> with your specific alarm code and <YOUR ALARM ENTITY ID> with your alarm entity id.
  2. Reboot Home Assistant.
  3. Scan the QR code available in your Home Assistant Notifications area (bottom-left badge) with your iPhone to add the alarm into the Apple Home app.

Multiple HomeKit bridges: If you have others HomeKit integrations created via the UI (i.e., Settings > Devices & Services), be careful to not use the same port twice to prevent conflicts. Also note, if you don't specify a port the default 21063 is used.

Please note that Apple Home requires you to confirm automations that involves security devices such as lockers and alarm systems.

As a result of the integration you should have a similar configuration in your Home app:

Alarm panel Alarm panel opened

Troubleshooting

If you encounter an issue, providing DEBUG logs can greatly assist us in identifying the bug. Please follow these steps to send us the debug logs:

  1. Navigate to the integration configuration page in Home Assistant: Settings > Devices & Services > e-Connect/Metronet Alarm.
  2. Enable debug logging by clicking on Enable debug logging.
  3. Restart the integration by selecting Restart from the three-dot menu.
  4. Reproduce the error (e.g., arm the system or modify the configuration).
  5. After reproducing the error, return to the Integration configuration page and click Disable debug logging.
  6. Your browser will prompt you to download the log file.
  7. Ensure that the logs do not contain sensitive information, as we do not log credentials or access tokens.
  8. Send the logs to us via a secure method. Do not post your logs on public platforms like our Discord general channel or GitHub issues, as they are publicly accessible.

Contributing

We are very open to the community's contributions - be it a quick fix of a typo, or a completely new feature! You don't need to be a Python expert to provide meaningful improvements. To learn how to get started, check out our Contributor Guidelines first, and ask for help in our Discord channel if you have questions.

Development

We welcome external contributions, even though the project was initially intended for personal use. If you think some parts could be exposed with a more generic interface, please open a GitHub issue to discuss your suggestion.

Dev Environment

To create a virtual environment and install the project and its dependencies, execute the following commands in your terminal:

# Initialize the environment with the latest version of Home Assistant
E_HASS_VERSION=$(curl --silent "https://api.github.com/repos/home-assistant/core/releases/latest" | grep -Po "(?<=\"tag_name\": \").*(?=\")")
./scripts/init $E_HASS_VERSION
source venv/bin/activate

# Install pre-commit hooks
pre-commit install

Instead, if you want to develop and test this integration with a different Home Assistant version, just pass the version to the init script:

# Initialize the environment Home Assistant 2024.1.1
./scripts/init 2024.1.1
source venv/bin/activate

# Install pre-commit hooks
pre-commit install

Testing Changes in Home Assistant

To test your changes in an actual Home Assistant environment, you may use the Docker container available in our compose.yaml file. Launch the container with the following command:

docker compose up -d

Then, navigate to http://localhost:8123 in your web browser to set up your Home Assistant instance. Follow the standard procedure to install the integration, as you would in a typical installation.

The container is configured to automatically mount the custom_components/ and config/ directories from your local workspace. To see changes reflected in Home Assistant, make sure to restart the instance through the UI each time you update the integration.

Coding Guidelines

To maintain a consistent codebase, we utilize flake8 and black. Consistency is crucial as it helps readability, reduces errors, and facilitates collaboration among developers.

To ensure that every commit adheres to our coding standards, we've integrated pre-commit hooks. These hooks automatically run flake8 and black before each commit, ensuring that all code changes are automatically checked and formatted.

For details on how to set up your development environment to make use of these hooks, please refer to the Development section of our documentation.

Testing

Ensuring the robustness and reliability of our code is paramount. Therefore, all contributions must include at least one test to verify the intended behavior.

To run tests locally, execute the test suite using pytest with the following command:

pytest tests --cov --cov-branch -vv

For a comprehensive test that mirrors the Continuous Integration (CI) environment across all supported Python versions, use tox:

tox

Note: To use tox effectively, ensure you have all the necessary Python versions installed. If any versions are missing, tox will provide relevant warnings.

ha-econnect-alarm's People

Contributors

andr3a88 avatar gervaso avatar palazzem avatar syth87 avatar xtimmy86x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ha-econnect-alarm's Issues

Unable to install version 2.0.1 through HACS

I have installed the latest HA and integration updates, the insertion status has not been automatically updated for about 2 weeks.
The integration communicates: I can activate and deactivate from HA, but if I deactivate or activate with mobile app or key, the new state does not appear in HA, the previous one remains.
If I reboot HA, everything is synced to the correct state upon reboot.
What can it be?

Add GitHub issue templates

Overview

To ensure consistency, include GitHub templates. Specifically:

  • Add GitHub PR template
  • Add GitHub Issue template

feat: add `triggered` status to alarm_control_panel entity

Is your feature request related to a problem? Please describe.
It would be useful to further enhance the entity by adding the triggered status when the panel has been activated by an alarm

Describe the solution you'd like
Add the triggered status in the alarm_control_panel entity

Describe alternatives you've considered

Additional context
It might be a good idea to use the value "2" of the alarm_led alert to retrieve the status

Create an integration global namespace for all inputs/sensors/metrics

Describe the bug

Currently, all metrics have no namespace as the other integrations. Examples are:

  • binary_sensor.alarm_led
  • binary_sensor.anomalies_led
  • binary_sensor.device_failure

Error message

n/a

Expected behavior

It's expected that all inputs, sectors and metrics have a namespace like: econnect_iess:

  • binary_sensor.econnect_iess_alarm_led
  • binary_sensor.econnect_iess_anomalies_led
  • binary_sensor.econnect_iess_device_failure

Additional context

This is an unavoidable breaking change.

To Reproduce

n/a

Environment

n/a

Unable to arm/disarm when scan interval is used

Describe the bug
When "Scan Interval" is set to a certain value (user reported 120s), the integration doesn't have a valid access token anymore, resulting in a 401 error.

Error message

Logger: custom_components.econnect_metronet.devices
Source: custom_components/econnect_metronet/devices.py:284
Integration: e-Connect/Metronet Alarm (documentation, issues)
First occurred: 18:16:42 (1 occurrences)
Last logged: 18:16:42

Device | Error while arming the system: "User not authenticated"
Errore 2:
Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/econnect_metronet/devices.py:280
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 18:16:42 (1 occurrences)
Last logged: 18:16:42

[547777283008] 401 Client Error: Unauthorized for url: https://connect.elmospa.com/api/panel/syncLogin
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 226, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2011, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 870, in entity_service_call
    response_data = await _handle_entity_call(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 942, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
File "/config/custom_components/econnect_metronet/decorators.py", line 26, in func_wrapper
  File "/config/custom_components/econnect_metronet/alarm_control_panel.py", line 121, in async_alarm_arm_night
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/econnect_metronet/devices.py", line 285, in arm
  File "/config/custom_components/econnect_metronet/devices.py", line 280, in arm
  File "/usr/local/lib/python3.11/contextlib.py", line 137, in enter
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/elmo/api/client.py", line 179, in lock
    raise err
  File "/usr/local/lib/python3.11/site-packages/elmo/api/client.py", line 173, in lock
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://connect.elmospa.com/api/panel/syncLogin

Expected behavior
Even if the access token is expired, it should be renewed so that the API call results in a proper 401 if and only if the actual authentication is not correct.

Additional context
This happens only if scan interval is set to a reasonable long period.

To Reproduce

  • Set scan interval to 120
  • Wait for the access token to expire
  • Launch an arm command before the scan interval refreshes the token

Environment

  • Operating System (OS): n/a
  • Library version (commit or version number): 2.2.1
  • Home Assistant version: n/a
  • Last working Home Assistant release (if known): n/a

Unable to disarm alarm for units that require a `userId`

Describe the bug
The integration is installed and configured without errors. When the alarm is armed, everything works as expected but disarming is not possibile as it returns "selected sectors 1 don't exist" in the logs.

Error message

2024-01-30 23:16:29.441 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140076357337536] Selected sectors don't exist: 1
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 238, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2149, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2186, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 882, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 952, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/econnect_metronet/decorators.py", line 26, in func_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/econnect_metronet/alarm_control_panel.py", line 98, in async_alarm_disarm
    await self.hass.async_add_executor_job(self._device.disarm, code)
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/econnect_metronet/devices.py", line 296, in disarm
    self._connection.disarm(sectors=sectors)
  File "/usr/local/lib/python3.11/site-packages/elmo/api/decorators.py", line 22, in func_wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/elmo/api/decorators.py", line 52, in func_wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/elmo/api/client.py", line 334, in disarm
    raise InvalidSector("Selected sectors don't exist: {}".format(invalid_sectors))
elmo.api.exceptions.InvalidSector: Selected sectors don't exist: 1

Expected behavior
As users can arm the alarm, it's expected they can also disarm it.

Additional context
User experiencing this issue has configured the alarm using 2 areas with 4 sectors each. The integration retrieves 8 sectors without distinguishing the areas.

To Reproduce
Not reproduced yet locally.

Environment

  • Operating System (OS): n/a
  • Library version (commit or version number): 2.2.1
  • Home Assistant version: n/a
  • Last working Home Assistant release (if known): n/a

Collect output sensors states

Is your feature request related to a problem? Please describe.

Currently, only inputs and areas are collected in the system. We should collect also the outputs as having their state is important for automations / system health.

Describe the solution you'd like

Modify econnect-python to collect outputs, and bring them inside this integration.

Describe alternatives you've considered

n/a

Additional context

n/a

Missing alarm panel states

Overview

Import from palazzem/econnect-python#103

--

**Stati non presenti: arm_custom_bypass, arm_vacation e arm_home **

Logger: homeassistant.components.websocket_api.http.connection
Source: helpers/service.py:851
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 20:48:27 (1 occurrences)
Last logged: 20:48:27

[548367750464] Entity alarm_control_panel.alarm_panel does not support this service.
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 226, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2011, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
return await service.entity_service_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 851, in entity_service_call
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity alarm_control_panel.alarm_panel does not support this service.

STATO SENSORI acceso/spento:
Inizialmente avevo inteso che i sensori fossero accessi/spenti quando inclusi o esclusi. in realtà, In caso di sensori volumetrici sono sempre spenti. Si accendono solo quando scattano. Quindi lo stato potrebbe portare a fraintendimenti tra acceso/spento e inclusi/esclusi

Integration config form: replace text inputs with entity lookup widgets

Is your feature request related to a problem? Please describe.
As a user I don't like setting numeric IDs to relate sectors with arm mode (i.e. setting 2,3,4 on the areas_arm_home field and son on).

Describe the solution you'd like
I'd prefer selecting sectors from the list of available ones on my current system

Describe alternatives you've considered
Discussed on Discord.

Additional context

This is how it currently works
image

This is how I'd like to set it up (simulated using the Add group UI feature)
image

Configuration failed after update to 2.2

With 2.1 installed PRX128 worked just find but after updating to 2.2 the configuration is stuck on a failed state and doesn't recognize entities anymore.

Error Message:
500 Internal Server Error Server got himself in trouble.

Trouble-shooting done:
tried to downgrade to 2.1: it worked but i can't arm or disarm anymore.
tried to delete all the previews onfigurations and repositories and tried to fresh install 2.2 again: no luck.

  • Operating System (OS): Linux 22.04 Server
  • Home Assistant version: 2023.11.3 container
  • Last working Home Assistant release (if known): 2023.11.3 with 2.1 pre update

Include the building step in CI

Describe the solution you'd like

It's important to have the build step that delivers the final package in our CI. This prevents developers to use their own machines/configurations to release a new package.

Describe alternatives you've considered

n/a

Additional context

n/a

UI bug when arming night sector after arming home away

Describe the bug

The bug is described here: palazzem/econnect-python#108

Error message

No errors, they system behaves correctly, but the UI doesn't.

Expected behavior

By arming "night", the UI must say "night".

Additional context

n/a

To Reproduce

  1. In the "away from home" configuration, I input 4 sectors.
  2. In the "night" configuration, I input only one sector.
  3. From the panel alarm_control_panel.alarm_panel "away from home", it arms all 4 sectors correctly for me.
  4. From the panel alarm_control_panel.alarm_panel "night", it arms only the sector I have entered.
  5. The UI bug is in the panel because when I activate "night", "away from home" appears as activated even though in reality only the night zone was correctly set.

Environment

  • Operating System (OS): 10.5
  • Supervisor 2023.08.1v
  • Home Assistant version: 2023.8.4

Sensors on/off descriptions are misleading (triggered/not triggered)

Is your feature request related to a problem? Please describe.

From @eliciogiuseppe (#103):

STATO SENSORI acceso/spento:
Inizialmente avevo inteso che i sensori fossero accessi/spenti quando inclusi o esclusi. in realtà, In caso di sensori volumetrici sono sempre spenti. Si accendono solo quando scattano. Quindi lo stato potrebbe portare a fraintendimenti tra acceso/spento e inclusi/esclusi

Translation (via ChatGPT):

Initially, I had understood that the sensors were on/off when included or excluded. In reality, in the case of volumetric sensors, they are always off. They only turn on when triggered. Therefore, the status might lead to confusion between on/off and included/excluded.

Describe the solution you'd like

Probably we should call the state differently, or anyway make it clear. On/off means that it works or not, and so an alarm user you think the sensor is enabled/disabled (included/excluded). This is misleading and we should change the wording.

Describe alternatives you've considered

n/a

Additional context

n/a

Enable/Disable sensors through switches

Is your feature request related to a problem? Please describe.
Sometimes I miss in HA a way to exclude/include a sensor, as can be done from econnect web UI

image

Describe the solution you'd like
I'd like to have an additional switch for every input sensor, that when toggled excludes/includes that sensor.
When a sensor is bypassed this way (excluded), arming any sector will ignore its status until it is included again.
The effect is persistent.
The API client already supports this action through the exclude/include methods.

Describe alternatives you've considered
There is no way to exclude a set of sensors in one shot - that is with a single call to the econnect api - as it just exposes primitives to toggle one single sensor at a time.
That said, it should be possible for the HA user to create groups of switches leveraging multiple calls under the hood.

Additional context
The action of excluding/including a sensor needs the same permissions as when arming a sector, so the client in turn has to acquire a lock and temporarily switch to write mode.
This means it has to provide the pin code.

Asking the pin code from UI is not feasible/desirable, so the code should be saved somewhere from the config flow.
OTOH the pin code must be handled carefully, as it is the key to arm/disarm the entire system and any leak would be harmful at least.

Getting the pin from the HA secrets would potentially disclose it to any other HA component/automation.
Furthermore HA support for secrets seems limited to reading contents from a secrets.yml file manually/externally edited by the user: this would be cumbersome for users lacking knowledge of yaml syntax.
So far I found no evidence of support or best practices for storing secrets other than through the secrets.yml file.
Also checking Alarmo project for a safe way to store and retrieve the pinCode, it seems that its use case is different, as it doesn't need to actually retrieve the original pin, but just its hash, so it uses bcrypt to validate it against the value submitted by the user.

A trivial way to encrypt/decrypt the pin for storage would be using a key obtained hashing some user info, such as the username and password, but clearly anyone having access to that info could do the same, so gaining access to the pin code.

High data usage on mobile networks

Describe the bug

Feedback from users:

I suggest you should work on “less data connection”. I’ve sim with 200 mb/month (easycontroll by Vodafone) but this integration is using 10-15mb per day… I’ve disinstalled waiting for such a modification. Anyhow, thanks for the great job!!!

Using the real time API (that is a long-polling strategy implemented by the company), increases by a lot data usage, making it a deal breaker for some users. As part of this task we should:

  1. Measure the current data usage (benchmarks with data usage)
  2. Check if other forms of polling are possible (making it not real-time may create unwanted delays, but it may be still good enough to some users)
  3. Check if it's possible to query directly the controller. This is the most expensive research as e-connect systems are closed sources and have no specifications published.

Error message
n/a

Expected behavior
The daily data usage is small

Additional context
This happens in all installations where a main controller is connected through a 4G/5G connection.

To Reproduce
n/a

Environment
n/a

`alarm_control_panel` status doesn't change correctly

Describe the bug
When the alarm switches from any armed state to another, the status doesn't change directly to the desired one, but first transitions to "armed_away".

Error message

Expected behavior
The status should change directly to the desired one.

Additional context

Screenshot_20231104_091159_Chrome

To Reproduce
Arm the control panel from armed_night to armed_home

Environment

  • Operating System (OS): HAOS
  • Library version (commit or version number): 2.1.0
  • Home Assistant version: 2023.11.1
  • Last working Home Assistant release (if known):

Support IESS Metronet system

Is your feature request related to a problem? Please describe.

Users are reporting that Elmo e-Connect system is the same as IESS Metronet system (it looks like Elmo is a parent company).
Given that, this library can support both systems if the base_url is changed.

Describe the solution you'd like

Provide a way to support both systems.

Describe alternatives you've considered

n/a

Additional context

Requires palazzem/econnect-python#111 to be merged.

Entity names are now the same as the Entity ID

Describe the bug

After the latest changes, the Entity Name is equal to the Entity ID. While this is not an issue, it could be better to restore the original change where the Entity name corresponds to a human readable value (e.g. "Sirena 1" or "Tapparella Sala").

Error message

n/a

Expected behavior

  • Have the entity name localized for the alarm panel
  • Have a human readable name for each input and sector.

Additional context

n/a

To Reproduce

  • Install the integration
  • Open any entity

Environment

  • Operating System (OS): any
  • Library version (commit or version number): any
  • Home Assistant version: any
  • Last working Home Assistant release (if known): any

Create binary_sensor only for configured sectors

Is your feature request related to a problem? Please describe.
Actually the integration create binary_sensor for all the sectors permitted in the control panel

Describe the solution you'd like
It would be better if the integration create only the sensors for the sectors configured in the control panel

Describe alternatives you've considered

Additional context
The sectors configured in the control panel are already managed by the query.SECTORS string of the API so is easy to manage the feature

HACS repository support

Is your feature request related to a problem? Please describe.
HACS simplifies a lot the deployment and updating of out-of-tree integrations in hassio.

Describe the solution you'd like
I would like for this integration to add HACS support.

Additional context
I'll provide a PR to add this feature

Collecting DEBUG logs requires too many manual steps

Describe the bug
To download DEBUG logs users can use the built-in UI functionality. Unfortunately, it just put the integration in debug mode and not the client itself, forcing users to update the configurations.yaml file manually, and to download the full logs.

Error message
No errors, it's a usability issue

Expected behavior
The built-in functionality should turn on the debug level also for elmo.* modules.

Additional context
n/a

To Reproduce
n/a

Environment

  • Operating System (OS):
  • Library version (commit or version number):
  • Home Assistant version:
  • Last working Home Assistant release (if known):

Data loss (no updates) when the connection is unstable

Describe the bug

Apparently, when the Internet connection is unstable, the integration remains stuck and HA doesn't receive data anymore from e-Connect cloud.

UPDATE 10/5/2023: this issue happened broadly when e-Connect servers went down for a while. It looks like the issue is not related to the Internet connection itself, but is related to a generic "connection instability". Maybe when there are a lot of errors in an integration or too many opened sockets, HA decides to deregister the component for safety or throttling.

UPDATE 10/6/2023: HA doesn't deregister the component and actually does the poll every 20 seconds (timeout time). The issue seems to be in the client.poll() method, that receives from the AlarmDevice a set of IDs that are too far in the future, to a point that they will never get updated. IDs retrieved from AlarmDevice are correct and based on the last call, but unfortunately the server resets the IDs when the connection with between the central unit and the cloud is interrupted.

Example:

# When it works
Polling IDs expected in the update: {9: 49, 10: 73}
Polling IDs registered in the device: {9: 49, 10: 73}

# When it doesn't
Polling IDs expected in the update: {9: 49, 10: 73}
Polling IDs registered in the device: {9: 6577, 10: 9865}

Error message

From logs:

Timeout fetching elmo_iess_alarm data

That said, the integration remains stuck and from that point it is not updated anymore.

Expected behavior

It is expected to have a timeout error, even though it's expected that the integration works as normal when the connection is back.

Additional context

To fix the problem is enough to reload the integration from the UI. A full restart is not required.

To Reproduce

  • The integration must work normally
  • Generate instability in your Internet connection (e.g. disconnect and reconnect multiple times)
  • Check the integration status

Environment

  • Operating System (OS): any
  • Library version (commit or version number): any
  • Home Assistant version: any
  • Last working Home Assistant release (if known): any

Missing translations generates a UI without text

Describe the bug

In the configuration config flow (options), text is missing.

Error message

n/a

Expected behavior

Text is present if a language other than English is used.

Additional context

n/a

To Reproduce

Set any language that is not English and open the options page.

Environment

  • Operating System (OS):
  • Library version (commit or version number):
  • Home Assistant version:
  • Last working Home Assistant release (if known):

GitHub actions don't work as `socket.socket` is accessed

Describe the bug

GitHub actions don't pass anymore as it looks like a default is changed. By accessing socket.socket in responses, pytest-socket is configured with --disable-socket triggering an exception and failing all tests that are using ElmoClient fixture.

Error message

cls = <class 'pytest_socket.disable_socket.<locals>.GuardedSocket'>
family = <AddressFamily.AF_INET: 2>, type = <SocketKind.SOCK_STREAM: 1>
proto = -1, fileno = None

    def __new__(cls, family=-1, type=-1, proto=-1, fileno=None):
        if _is_unix_socket(family) and allow_unix_socket:
            return super().__new__(cls, family, type, proto, fileno)
    
>       raise SocketBlockedError()
E       pytest_socket.SocketBlockedError: A test tried to use socket.socket.

Expected behavior

It should work as before.

Additional context

n/a

To Reproduce

Just open any PR.

Environment

  • Operating System (OS):
  • Library version (commit or version number):
  • Home Assistant version:
  • Last working Home Assistant release (if known):

Constant deprecated in future HA Core 2025.1

Describe the bug
Constant deprecated in the future Home Assistant Core 2025.1. Some warning appears in the log.

Error message

hass-dev  | 2024-02-01 15:54:47.500 WARNING (MainThread) [homeassistant.components.alarm_control_panel] FORMAT_NUMBER was used from econnect_metronet, this is a deprecated constant which will be removed in HA Core 2025.1. Use CodeFormat.NUMBER instead, please create a bug report at https://github.com/palazzem/ha-econnect-alarm/issues
hass-dev  | 2024-02-01 15:54:47.502 WARNING (MainThread) [homeassistant.components.alarm_control_panel] FORMAT_NUMBER was used from econnect_metronet, this is a deprecated constant which will be removed in HA Core 2025.1. Use CodeFormat.NUMBER instead, please create a bug report at https://github.com/palazzem/ha-econnect-alarm/issues
hass-dev  | 2024-02-01 15:54:47.503 WARNING (MainThread) [homeassistant.components.alarm_control_panel.const] SUPPORT_ALARM_ARM_AWAY was used from econnect_metronet, this is a deprecated constant which will be removed in HA Core 2025.1. Use AlarmControlPanelEntityFeature.ARM_AWAY instead, please create a bug report at https://github.com/palazzem/ha-econnect-alarm/issues
hass-dev  | 2024-02-01 15:54:47.505 WARNING (MainThread) [homeassistant.components.alarm_control_panel.const] SUPPORT_ALARM_ARM_HOME was used from econnect_metronet, this is a deprecated constant which will be removed in HA Core 2025.1. Use AlarmControlPanelEntityFeature.ARM_HOME instead, please create a bug report at https://github.com/palazzem/ha-econnect-alarm/issues
hass-dev  | 2024-02-01 15:54:47.506 WARNING (MainThread) [homeassistant.components.alarm_control_panel.const] SUPPORT_ALARM_ARM_NIGHT was used from econnect_metronet, this is a deprecated constant which will be removed in HA Core 2025.1. Use AlarmControlPanelEntityFeature.ARM_NIGHT instead, please create a bug report at https://github.com/palazzem/ha-econnect-alarm/issues
hass-dev  | 2024-02-01 15:54:47.508 WARNING (MainThread) [homeassistant.components.alarm_control_panel.const] SUPPORT_ALARM_ARM_VACATION was used from econnect_metronet, this is a deprecated constant which will be removed in HA Core 2025.1. Use AlarmControlPanelEntityFeature.ARM_VACATION instead, please create a bug report at https://github.com/palazzem/ha-econnect-alarm/issues

###########################################

FORMAT_NUMBER was used from econnect_metronet, this is a deprecated constant which will be removed in HA Core 2025.1. Use CodeFormat.NUMBER instead

############################################

Expected behavior
No warnings in the log

To Reproduce
Install HA Core 2024.1

Environment

  • Operating System (OS): HA in a MiniPC
  • Library version (commit or version number): 2.2.1
  • Home Assistant version: 2024.1.1
  • Last working Home Assistant release (if known): 2023.12.X

feat: Add multiple 'alarm_control_panel'

Is your feature request related to a problem? Please describe.
In some installations, it may occur that within the same panel, there are multiple distinct areas.
It would be useful to have separate alarm_control_panel entities for each area.

Describe the solution you'd like
It should be good that we can set multiple alarm_control_panel entities in the config flow and assign which sectors belong to each entity

Describe alternatives you've considered

Additional context

Handle `arm_custom_bypass` mode

Imported from palazzem/econnect-python#102

Original:

Esclusione personalizzata, andando a scegliere il sensore o la "zona" ovvero perimetrale, piano 1, 2 ecc da inserire/disinserire; quindi ad esempio quando attiviamo l'allarme includendo tutto potremmo escludere parte dei sensori (perchè c'è un guasto) o una intera zona, oppure attraverso una schermata includere/escludere determinate zone/sensori

esempio: clicco su esclusione, mi chiede quali zone voglio attivare/disattivare (non so se è possibile anche attivare determinati sensori ma questa è una cosa che viene fatta direttamente in fase di programmazione delle centrale creando una zona) e attiva magari il perimetrale con la zona giorno lasciando scoperta solo la zona notte e includendo il sensore del garage che si trova nella zona notte

Translation (reworded with ChatGPT):

"Custom exclusion feature needed: when selecting a sensor or "zone" such as perimeter, floor 1, floor 2, etc. to activate/deactivate. For instance, when turning on the alarm for the whole property, we should have the option to exclude a specific part of the house or a particular zone (via arm_custom_bypass mode)."

Import `AlarmDevice`

Is your feature request related to a problem? Please describe.

After merging this PR (palazzem/econnect-python#113), AlarmDevice is not available anymore. We should reimport it in this repository.

Describe the solution you'd like

Add AlarmDevice in this repository.

Describe alternatives you've considered

n/a

Additional context

n/a

Several logging of "Centrale non connessa" and sensors unavailable during reconnection

Describe the bug
Several logging of "Centrale non connessa" and sensors unavailable during reconnection.

Error message
2024-01-22 11:13:13.883 ERROR (SyncWorker_3) [custom_components.econnect_metronet.devices] Device | Error during the update: "Centrale non connessa" 2024-01-22 11:13:18.816 ERROR (MainThread) [custom_components.econnect_metronet.coordinator] Coordinator | Central unit disconnected, forcing a full update

Environment

  • Operating System (OS): HAOS 11.4
  • Library version (commit or version number): 2.2.1
  • Home Assistant version: 2024.1.3
  • Last working Home Assistant release (if known): -

Add an official icon

Is your feature request related to a problem? Please describe.

Currently the integration is not showing any icon. We should provide an icon to represent the e-Connect cloud.

Describe the solution you'd like

Prepare an e-Connect icon and add it to official repository: https://github.com/home-assistant/brands

Describe alternatives you've considered

n/a

Additional context

We should take in consideration that we support also IESS, so we should pay attention to what icon are we adding there.

Users can configure AWAY state if needed

Is your feature request related to a problem? Please describe.

For some users enabling the AWAY state doesn't mean activating all sectors. We may want to provide a way to let them configure sectors for all possible alarm states.

Describe the solution you'd like

  1. Add a configuration where users can configure their AWAY sectors.
  2. If AWAY sectors are not configured, enable all sectors (backward compatibility).

Describe alternatives you've considered

n/a

Additional context

n/a

Error logs are not describing the real issue returned by the cloud API

Describe the bug
When you try to arm a sector that is not ready, you receive a warning notifying you that the sector does not exist but is not correct.

Error message
Screenshot 2023-12-01 230429

Expected behavior
A warning that notifies you that you have tried to arm a sector that is not ready.

Additional context
This is the situation in webapp when a sector is not ready
Screenshot 2023-12-01 232725

To Reproduce
Try to arm a sector not ready and see the log

Environment

  • Operating System (OS):
  • Library version (commit or version number):
  • Home Assistant version:
  • Last working Home Assistant release (if known):

feat: treat `alarm_led`, `tamper_led` and `inputs_led` as sensors

Is your feature request related to a problem? Please describe.
The led sensors report 3 state from API but we use as binary_sensor with only 2 state (true and false)

Describe the solution you'd like
We transform alarm_led, tamper_led and inputs_led in sensor with a text reported status
0: No Alarm
1: Memory Alarm
2: Alarm

Describe alternatives you've considered

Additional context

refactor: rename the integration as `econnect_metronet`

Is your feature request related to a problem? Please describe.

The integration is currently named elmo_iess_alarm, which denotes an integration with Elmo and IESS devices. However, in reality, this integration connects to e-Connect (El.mo.) and Metronet (IESS) cloud services. Therefore, it would be more accurate to name it based on the technology used to retrieve HA entities.

Describe the solution you'd like

Rename the integration as econnect_metronet.

Describe alternatives you've considered

Keep the integration name as it is right now, even though it looks like El.mo. uses e-Connect all the time for their web and mobile apps.

Additional context

This is a follow-up decision the community discussed in the #47 issue.

Define 'CONFIG_SCHEMA', 'PLATFORM_SCHEMA' or 'PLATFORM_SCHEMA_BASE'

Error message

From hassfest:

Warning: G] [CONFIG_SCHEMA] Integrations which implement 'async_setup' or 'setup' must define either
'CONFIG_SCHEMA', 'PLATFORM_SCHEMA' or 'PLATFORM_SCHEMA_BASE'. If the integration has no configuration
parameters, can only be set up from platforms or can only be set up from config entries, one of the helpers
cv.empty_config_schema, cv.platform_only_config_schema or cv.config_entry_only_config_schema can be used.

Expected behavior

Hassfest should not raise any warning.

Additional context

n/a

To Reproduce

n/a

Environment

Continuous Integration (GitHub actions)

Use econnect-python `get_status()` to collect anomalies/alarms/tampering `binary_sensor`

Is your feature request related to a problem? Please describe.

The latest version of econnect-python implements a new API get_status() that retrieves the alarm system global state. We should use it to expose to users more binary sensors to trigger automations for anomalies, alarms or when tampering is detected.

Describe the solution you'd like

Transform the result of get_status() in binary_sensor.

Describe alternatives you've considered

n/a

Additional context

n/a

Refactor `AlarmCoordinator` so that it's not a polling coordinator

Is your feature request related to a problem? Please describe.

AlarmCoordinator introduced in #74 is a polling integration built on top of a long-polling API. The combination of both means that you poll every 5 seconds, then you are stuck for at most 15 seconds, to then poll again. This introduces unneeded latency as you don't need to wait for the next poll, but you can:

  1. Poll
  2. If not changed, poll again
  3. If changed, update
  4. Poll again

Describe the solution you'd like

The long-polling triggers a signal to notify the integration that an update is needed, so we can simply poll and when there is a change, retrieve the data and publish it through async_set_updated_data().

We can still keep AlarmDevice in place, with no need of changing how entities get updated. That could be a further step.

Describe alternatives you've considered

Keep everything as it is, even though it introduces 5 seconds latency if you wait for the next poll to happen.

Additional context

The polling mechanism must be configurable, as it's needed by some customers that don't want to keep the connection always opened with the cloud.

Configure `hatch` to build directly a .ZIP folder

Describe the bug

When we use the release process (and the artifact publishing), the builder creates a tar.gz file. When the file is downloaded, GitHub sends it back as a ZIP file creating an archive of an archive.

This is not seen by Mac users as the unarchiver automatically extracts all the archives.

Error message

None, it's just not user friendly.

Expected behavior

A single ZIP file with everything inside.

Additional context

n/a

To Reproduce

Download any pre-release: https://github.com/palazzem/ha-econnect-alarm/releases/tag/v0.3.0.dev3

Environment

  • Operating System (OS):
  • Library version (commit or version number):
  • Home Assistant version:
  • Last working Home Assistant release (if known):

Release workflow doesn't release tar/zip packages.

Describe the bug

The build system doesn't work and doesn't release the tar/zip packages.

Error message

🤔 Pattern '/home/runner/work/ha-econnect-alarm/ha-econnect-alarm/dist/econnect_metronet-$PKG_VERSION.tar.gz' does not match any files.
🤔 Pattern '/home/runner/work/ha-econnect-alarm/ha-econnect-alarm/dist/econnect_metronet-$PKG_VERSION.zip' does not match any files.

Expected behavior

It must publish both of them.

Additional context

$PKG_VERSION variable is not expanded. We should probably use {{ x }} notation.

To Reproduce

https://github.com/palazzem/ha-econnect-alarm/actions/runs/6482746561/job/17602861706

Environment

CI

Invalid authentication

Describe the bug
During the set up of the integration with IESS/Metronet credentials I am unable to authenticate, while I am sure that user and password are correct. Thanks for your help.

Error message
"invalid authentication"

Expected behavior
proceed with the installation of the integration

Environment

  • Operating System (OS): HASS in a VM
  • Library version (commit or version number): 2.2.1
  • Home Assistant version: 2023.12.2
  • Last working Home Assistant release (if known): none

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.