Skip to content

Commit 3b76e3d

Browse files
authored
Add device class for sensor state translation (#60)
1 parent f161335 commit 3b76e3d

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

{{cookiecutter.project_name}}/custom_components/{{cookiecutter.domain_name}}/sensor.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
from homeassistant.util import slugify
66

7-
from homeassistant.util import slugify
8-
97

108
async def async_setup_entry(hass, entry, async_add_devices):
119
"""Setup sensor platform."""
@@ -31,3 +29,8 @@ def state(self):
3129
def icon(self):
3230
"""Return the icon of the sensor."""
3331
return ICON
32+
33+
@property
34+
def device_class(self):
35+
"""Return de device class of the sensor."""
36+
return "{{cookiecutter.domain_name}}__custom_device_class"

{{cookiecutter.project_name}}/custom_components/{{cookiecutter.domain_name}}/translations/sensor.en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"state": {
3-
"_": {
3+
"{{cookiecutter.domain_name}}__custom_device_class": {
44
"some_sample_static_text": "Some sample static text."
55
}
66
}

{{cookiecutter.project_name}}/custom_components/{{cookiecutter.domain_name}}/translations/sensor.fr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"state": {
3-
"_": {
3+
"{{cookiecutter.domain_name}}__custom_device_class": {
44
"some_sample_static_text": "Exemple de texte statique."
55
}
66
}

{{cookiecutter.project_name}}/custom_components/{{cookiecutter.domain_name}}/translations/sensor.nb.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"state": {
3-
"_": {
3+
"{{cookiecutter.domain_name}}__custom_device_class": {
44
"some_sample_static_text": "Eksempel tekst."
55
}
66
}

0 commit comments

Comments
 (0)