diff --git a/.devcontainer/configuration.yaml b/.devcontainer/configuration.yaml index 96b29dd..83e8976 100644 --- a/.devcontainer/configuration.yaml +++ b/.devcontainer/configuration.yaml @@ -11,6 +11,3 @@ logger: binary_sensor: - platform: car_wash weather: weather.home_assistant - -weather: - - platform: demo diff --git a/README.md b/README.md index 89872a1..cf71305 100644 --- a/README.md +++ b/README.md @@ -55,10 +55,6 @@ binary_sensor: This sensor should work with any weather provider in any of it settings. But please note that the sensor cannot see further than the weather provider shows. Therefore, it is recommended to set the `daily` mode in the weather provider settings. If necessary, you can configure a separate weather provider instance especially for this sensor. -> **_Note_**:\ -> Unfortunately, the binary sensor can show only two states — “on” and “off”. -> In the case of this sensor, “on” should be interpreted as *“it is worth washing the car”*, and “off” — as *“you should not wash the car”*. -

* * *

I put a lot of work into making this repo and component available and updated to inspire and help others! I will be glad to receive thanks from you — it will give me new strength and add enthusiasm:


diff --git a/custom_components/car_wash/binary_sensor.py b/custom_components/car_wash/binary_sensor.py index 5a9fdbd..50e4717 100644 --- a/custom_components/car_wash/binary_sensor.py +++ b/custom_components/car_wash/binary_sensor.py @@ -97,6 +97,11 @@ def should_poll(self): """No polling needed.""" return False + @property + def device_class(self): + """Return the class of this device, from component DEVICE_CLASSES.""" + return f"{DOMAIN}__" + @property def name(self): """Return the name of the sensor.""" diff --git a/custom_components/car_wash/const.py b/custom_components/car_wash/const.py index acfb33d..be8ebe9 100644 --- a/custom_components/car_wash/const.py +++ b/custom_components/car_wash/const.py @@ -22,7 +22,7 @@ # Base component constants NAME = "Car Wash" DOMAIN = "car_wash" -VERSION = "1.2.17" +VERSION = "1.2.18.dev0" ISSUE_URL = "https://github.com/Limych/ha-car_wash/issues" STARTUP_MESSAGE = f""" diff --git a/custom_components/car_wash/manifest.json b/custom_components/car_wash/manifest.json index 4b71717..0205b5e 100644 --- a/custom_components/car_wash/manifest.json +++ b/custom_components/car_wash/manifest.json @@ -1,7 +1,7 @@ { "domain": "car_wash", "name": "Car Wash", - "version": "1.2.17", + "version": "1.2.18.dev0", "documentation": "https://github.com/Limych/ha-car_wash", "issue_tracker": "https://github.com/Limych/ha-car_wash/issues", "dependencies": [ diff --git a/custom_components/car_wash/translations/binary_sensor.en.json b/custom_components/car_wash/translations/binary_sensor.en.json new file mode 100644 index 0000000..ecaabd6 --- /dev/null +++ b/custom_components/car_wash/translations/binary_sensor.en.json @@ -0,0 +1,8 @@ +{ + "state": { + "car_wash__": { + "off": "Should not wash", + "on": "Worth wash" + } + } +} diff --git a/custom_components/car_wash/translations/binary_sensor.ru.json b/custom_components/car_wash/translations/binary_sensor.ru.json new file mode 100644 index 0000000..eafb4f1 --- /dev/null +++ b/custom_components/car_wash/translations/binary_sensor.ru.json @@ -0,0 +1,8 @@ +{ + "state": { + "car_wash__": { + "off": "Нет смысла мыть", + "on": "Стоит помыть" + } + } +} diff --git a/tests/test_binary_sensor.py b/tests/test_binary_sensor.py index 2f2aff1..2f9a030 100644 --- a/tests/test_binary_sensor.py +++ b/tests/test_binary_sensor.py @@ -1,4 +1,4 @@ -"""The test for the average sensor platform.""" +"""The test for the binary sensor platform.""" # pylint: disable=redefined-outer-name import pytest from homeassistant.components.weather import ( @@ -60,8 +60,9 @@ async def test_entity_initialization(hass: HomeAssistant): """Test sensor initialization.""" entity = CarWashBinarySensor(hass, "test", "weather.test_monitored", 2) - assert entity.name == "test" assert entity.unique_id == "car_wash-test_monitored" + assert entity.name == "test" + assert entity.device_class == f"{DOMAIN}__" assert entity.should_poll is False assert entity.available is False assert entity.is_on is None