Skip to content

Commit

Permalink
Add translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Limych committed Mar 17, 2021
1 parent 913f762 commit cc5b7fb
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .devcontainer/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ logger:
binary_sensor:
- platform: car_wash
weather: weather.home_assistant

weather:
- platform: demo
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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”*.

<p align="center">* * *</p>
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:
<p align="center"><br>
Expand Down
5 changes: 5 additions & 0 deletions custom_components/car_wash/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/car_wash/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/car_wash/manifest.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
8 changes: 8 additions & 0 deletions custom_components/car_wash/translations/binary_sensor.en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"state": {
"car_wash__": {
"off": "Should not wash",
"on": "Worth wash"
}
}
}
8 changes: 8 additions & 0 deletions custom_components/car_wash/translations/binary_sensor.ru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"state": {
"car_wash__": {
"off": "Нет смысла мыть",
"on": "Стоит помыть"
}
}
}
5 changes: 3 additions & 2 deletions tests/test_binary_sensor.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cc5b7fb

Please sign in to comment.