Commit graph

751 commits

Author SHA1 Message Date
Maciej Bieniek
efc1ff6eff
Fix Shelly update entity names (#126512) 2024-09-23 14:18:24 +02:00
Simone Chemelli
99a65d3098
Fix update platform for Shelly gen1 devices (#124798) 2024-09-20 15:57:32 +02:00
Maciej Bieniek
6906ee0e48
Improve Shelly RPC entity naming (#125415)
* Fix default names for cover entities

* Drop component index if only one component exists

* Improve doc strings

* Use more consistent naming

* Typo

* Revert removing index 0 from entity names

* Improve names for RGB(W) lights
2024-09-15 11:29:26 +02:00
epenet
6ef1dd56f5
Use root import for device_automation (#125836) 2024-09-12 17:01:25 +02:00
Maciej Bieniek
da401cafdf
Add support for cover tilt for Shelly 2PM Gen3 (#125717)
* Add support for tilt

* Fix config

* Add test

* Increase test coverage
2024-09-12 09:28:36 +02:00
Shay Levy
99f43400bf
Bump aioshelly to 11.4.2 (#125036) 2024-09-01 11:08:19 -10:00
J. Nick Koston
460363c4ba
Bump aioshelly to 11.4.1 to accomodate shelly GetStatus calls that take a few seconds to respond (#124893)
Co-authored-by: Shay Levy <levyshay1@gmail.com>
2024-08-30 09:05:16 -10:00
J. Nick Koston
f9bf7f7e05
Small cleanups to shelly (#124758) 2024-08-27 21:00:31 -10:00
J. Nick Koston
a63c5e6725
Cache shelly coordinator properties that never change (#124756) 2024-08-27 21:00:20 -10:00
J. Nick Koston
5bd17c9198
Bump aioshelly to 11.3.0 (#124741) 2024-08-27 12:34:30 -10:00
Shay Levy
467749eb57
Fix Shelly sleepy RPC setup if device is already awake (#124734) 2024-08-27 10:48:13 -10:00
Maciej Bieniek
b960ebeb8b
Add WS outbound config to Shelly diagnostics (#124654)
Add WS Outbound config to diagnostics
2024-08-26 22:17:38 +03:00
Maciej Bieniek
d8fe3c5377
Add missing units for xpercent, xfreq and xcounts Shelly sensors (#124288) 2024-08-26 08:59:18 -10:00
J. Nick Koston
76182c246d
Auto configure outbound websocket for sleepy shelly RPC devices (#124545) 2024-08-26 08:37:36 -10:00
J. Nick Koston
be206156b0
Fix shelly sleepy entities never being created (#124547) 2024-08-25 09:21:23 -10:00
J. Nick Koston
df82567356
Fix shelly available check when device is not initialized (#124182)
* Fix shelly available check when device is not initialized

available needs to check for device.initialized or if the device
is sleepy as calls to status will raise NotInitialized which results
in many unretrieved exceptions while writing state

fixes
```
2024-08-18 09:33:03.757 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 453, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
    update_callback()
  File "/config/custom_components/shelly/entity.py", line 374, in _update_callback
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1005, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1130, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1067, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1011, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 293, in state
    if (is_on := self.is_on) is None:
                 ^^^^^^^^^^
  File "/config/custom_components/shelly/binary_sensor.py", line 331, in is_on
    return bool(self.attribute_value)
                ^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/shelly/entity.py", line 545, in attribute_value
    self._last_value = self.sub_status
                       ^^^^^^^^^^^^^^^
  File "/config/custom_components/shelly/entity.py", line 534, in sub_status
    return self.status[self.entity_description.sub_key]
           ^^^^^^^^^^^
  File "/config/custom_components/shelly/entity.py", line 364, in status
    return cast(dict, self.coordinator.device.status[self.key])
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioshelly/rpc_device/device.py", line 390, in status
    raise NotInitialized
aioshelly.exceptions.NotInitialized
```

* tweak

* cover

* fix

* cover

* fixes
2024-08-22 16:14:45 +03:00
J. Nick Koston
d8cbb3540f
Bump aioshelly to 11.2.4 (#124080) 2024-08-19 19:13:35 -05:00
Shay Levy
49c59339d9
Shelly RPC - do not stop BLE scanner if a sleeping device (#124147) 2024-08-18 18:35:02 +03:00
Maciej Bieniek
ec0012209d
Add missing sensors for Shelly Plus RGBW PM (#123589)
* Add missing sensors for Shelly Plus RGBW PM

* Add tests
2024-08-18 12:58:51 +03:00
Maciej Bieniek
a040f1a9d1
Bump aioshelly to version 11.2.0 (#123602)
Bump aioshelly to version 11.2.0
2024-08-11 20:56:12 +03:00
Shay Levy
8687c32c15
Ignore Shelly IPv6 address in zeroconf (#123081) 2024-08-02 21:56:49 +03:00
epenet
5e1cca1c58
Fix implicit-return in shelly (#122926) 2024-07-31 14:54:52 +02:00
huettner94
eb3686af06
Add shelly overcurrent sensor for switches (#122494)
shelly: add overcurrent sensor for switches

just like overvoltage shelly switches can react to overcurrent and
diable the switch. Unfortunately this is is not mentioned anywhere in
the documentation.
It can be triggered by a device using more amps than set in
"Output protections" under the name "Overcurrent in amperes".
2024-07-25 21:22:18 +03:00
Shay Levy
d2cc25cee6
Prevent connecting to a Shelly device that is already connected (#122105) 2024-07-18 15:27:03 -05:00
Maciej Bieniek
bf0e5baa76
Add support for Shelly enum virtual component (#121997)
* Support enum virtual component

* Add tests

* Cleaning

* Improve test for select

* Use values

* Update tests

* Use the option title for sensor

---------

Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
2024-07-18 17:55:14 +03:00
Maciej Bieniek
14ec7e5f76
Set DeviceInfo.model_id in Shelly integration (#122040) 2024-07-17 09:04:40 +02:00
Maciej Bieniek
260e98c3f7
Add support for Shelly number virtual component (#121894)
* Support number component in field mode

* Support number in label mode

* Add tests

* Add mode_fn

* Add support for number component in slider mode

* Add comment

* Suggested change

* Revert max_fn

* Change unit 'min' to 'Hz' in test

---------

Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
2024-07-15 22:26:12 +02:00
Maciej Bieniek
50751574b4
Fix configuration_url for Shelly device using IPv6 (#121939)
Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
2024-07-15 08:31:44 +02:00
Maciej Bieniek
3ef1e5816e
Add support for Shelly text virtual component (#121735)
* Add support for text component

* Add tests

* Improve const names

* Remove unnecessary code

---------

Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
2024-07-12 12:58:21 +02:00
Shay Levy
cdb26ef8a3
Cleanup Shelly unused strings for removed valve switch (#121813) 2024-07-12 05:44:25 +01:00
Maciej Bieniek
70f05e5f13
Add support for Shelly virtual boolean component (#119932)
Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
2024-07-10 23:51:51 +02:00
Maciej Bieniek
dbe98de82a
Fix pulse counter frequency sensors for Shelly Plus Uni (#121178)
Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
2024-07-05 09:40:43 +02:00
Shay Levy
b5367e5994
Fix Shelly device shutdown (#120881) 2024-07-01 19:06:56 +02:00
Maciej Bieniek
c029c534d6
Do not call async_delete_issue() if there is no issue to delete in Shelly integration (#120762)
Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
2024-06-28 19:34:24 +03:00
Shay Levy
4c6cbadc11
Align Shelly sleeping devices timeout with non-sleeping (#118969) 2024-06-26 20:53:02 +02:00
Shay Levy
d8ab2debfd
Add last_error reporting to Shelly diagnostics (#120595) 2024-06-26 21:35:23 +03:00
Shay Levy
ed1eb8ac9c
Change Shelly connect task log message level to error (#120582) 2024-06-26 18:19:28 +02:00
Shay Levy
57e615aa36
Don't log Shelly push update failures if there are no errors (#120189) 2024-06-23 00:36:58 +03:00
Maciej Bieniek
54f8b5afdf
Add pulse counter frequency sensors to Shelly (#119898)
* Add pulse counter frequency sensors

* Cleaning

---------

Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
2024-06-18 23:08:30 +02:00
Maciej Bieniek
f5dfefb3a6
Use the humidity value in Shelly Wall Display climate entity (#119830)
* Use the humidity value with the climate entity if available

* Update tests

* Use walrus

---------

Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
2024-06-17 23:17:05 +03:00
Maciej Bieniek
87c1d5a6a7
Remove the switch entity for Shelly Gas Valve (#119817)
Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
2024-06-17 19:17:06 +02:00
Shay Levy
b20160a465
Cleanup Shelly entry unload (#119748)
* Cleanup Shelly entry unload

* store platforms on runtime_data
2024-06-16 08:25:23 -05:00
Shay Levy
efa7240ac5
Use single list for Shelly non-sleeping platforms (#119540) 2024-06-13 20:27:40 -05:00
J. Nick Koston
dbd3147c9b
Remove async_late_forward_entry_setups and instead implicitly hold the lock (#119088)
* Refactor config entry forwards to implictly obtain the lock instead of explictly

This is a bit of a tradeoff to not need async_late_forward_entry_setups

The downside is we can no longer detect non-awaited plastform setups
as we will always implicitly obtain the lock instead of explictly.

Note, this PR is incomplete and is only for discussion purposes
at this point

* preen

* cover

* cover

* restore check for non-awaited platform setup

* cleanup

* fix missing word

* make non-awaited test safer
2024-06-12 21:06:11 -04:00
Shay Levy
04222c32b5
Handle Shelly BLE errors during connect and disconnect (#119174) 2024-06-09 11:59:40 +02:00
Shay Levy
742dd61d36
Bump aioshelly to 10.0.1 (#119123) 2024-06-08 10:44:37 +02:00
Shay Levy
9a6902d827
Hold connection lock in Shelly RPC reconnect (#119009) 2024-06-07 09:50:05 +02:00
J. Nick Koston
ed0568c655
Ensure config entries are not unloaded while their platforms are setting up (#118767)
* Report non-awaited/non-locked config entry platform forwards

Its currently possible for config entries to be reloaded while their platforms
are being forwarded if platform forwards are not awaited or done after the
config entry is setup since the lock will not be held in this case.

In https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards
we advised to await platform forwards to ensure this does not happen, however
for sleeping devices and late discovered devices, platform forwards may happen
later.

If config platform forwards are happening during setup, they should be awaited

If config entry platform forwards are not happening during setup, instead
async_late_forward_entry_setups should be used which will hold the lock to
prevent the config entry from being unloaded while its platforms are being
setup

* Report non-awaited/non-locked config entry platform forwards

Its currently possible for config entries to be reloaded while their platforms
are being forwarded if platform forwards are not awaited or done after the
config entry is setup since the lock will not be held in this case.

In https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards
we advised to await platform forwards to ensure this does not happen, however
for sleeping devices and late discovered devices, platform forwards may happen
later.

If config platform forwards are happening during setup, they should be awaited

If config entry platform forwards are not happening during setup, instead
async_late_forward_entry_setups should be used which will hold the lock to
prevent the config entry from being unloaded while its platforms are being
setup

* run with error on to find them

* cert_exp, hold lock

* cert_exp, hold lock

* shelly async_late_forward_entry_setups

* compact

* compact

* found another

* patch up mobileapp

* patch up hue tests

* patch up smartthings

* fix mqtt

* fix esphome

* zwave_js

* mqtt

* rework

* fixes

* fix mocking

* fix mocking

* do not call async_forward_entry_setup directly

* docstrings

* docstrings

* docstrings

* add comments

* doc strings

* fixed all in core, turn off strict

* coverage

* coverage

* missing

* coverage
2024-06-04 21:34:39 -04:00
Maciej Bieniek
709e32a38a
Check if Shelly entry.runtime_data is available (#118805)
* Check if runtime_data is available

* Add tests

* Use `is` operator

---------

Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
2024-06-04 18:40:18 +02:00
epenet
e7ce01e649
Enforce namespace import in components (#118218) 2024-05-27 12:50:11 +02:00