Skip to content

Commit

Permalink
Some changes, support fr and pl, solved #21 #22
Browse files Browse the repository at this point in the history
Some changes:
- support fr and pl translations
- solved #21 #22
  • Loading branch information
dave-code-ruiz authored Apr 24, 2023
1 parent 5551fd4 commit 96e389b
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 116 deletions.
5 changes: 2 additions & 3 deletions custom_components/elkbledom/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any

from homeassistant import config_entries
from homeassistant.const import CONF_MAC, CONF_MODEL
from homeassistant.const import CONF_MAC
import voluptuous as vol
from homeassistant.helpers.device_registry import format_mac
from homeassistant.data_entry_flow import FlowResult
Expand All @@ -14,7 +14,6 @@
)
from bluetooth_sensor_state_data import BluetoothData
from home_assistant_bluetooth import BluetoothServiceInfo
from homeassistant.helpers.selector import selector

from .const import DOMAIN, CONF_RESET
import logging
Expand All @@ -30,7 +29,7 @@ def __init__(self, discovery_info) -> None:
self._discovery = discovery_info

def supported(self):
return self._discovery.name.lower().startswith("elk-ble") or self._discovery.name.lower().startswith("ledble") or self._discovery.name.lower().startswith("melk")
return self._discovery.name.lower().startswith("elk-ble") or self._discovery.name.lower().startswith("elk-bulb") or self._discovery.name.lower().startswith("ledble") or self._discovery.name.lower().startswith("melk")

def address(self):
return self._discovery.address
Expand Down
14 changes: 7 additions & 7 deletions custom_components/elkbledom/elkbledom.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
# [be:59:7a:00:08:d5][LE]>

# CHANGES ARRAYS TO DICT OR MODELDB OBJECT WITH ALL MODEL INFORMATION
NAME_ARRAY = ["ELK-BLE", "LEDBLE", "MELK"]
WRITE_CHARACTERISTIC_UUIDS = ["0000fff3-0000-1000-8000-00805f9b34fb", "0000ffe1-0000-1000-8000-00805f9b34fb", "0000fff3-0000-1000-8000-00805f9b34fb"]
READ_CHARACTERISTIC_UUIDS = ["0000fff4-0000-1000-8000-00805f9b34fb", "0000ffe2-0000-1000-8000-00805f9b34fb", "0000fff4-0000-1000-8000-00805f9b34fb"]
TURN_ON_CMD = [[0x7e, 0x00, 0x04, 0xf0, 0x00, 0x01, 0xff, 0x00, 0xef],[0x7e, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0xef], bytearray([0x7e, 0x07, 0x83])]
TURN_OFF_CMD = [[0x7e, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0x00, 0xef], [0x7e, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0x00, 0xef], bytearray([0x7e, 0x04, 0x04])]
NAME_ARRAY = ["ELK-BLE", "LEDBLE", "MELK", "ELK-BULB"]
WRITE_CHARACTERISTIC_UUIDS = ["0000fff3-0000-1000-8000-00805f9b34fb", "0000ffe1-0000-1000-8000-00805f9b34fb", "0000fff3-0000-1000-8000-00805f9b34fb", "0000fff3-0000-1000-8000-00805f9b34fb"]
READ_CHARACTERISTIC_UUIDS = ["0000fff4-0000-1000-8000-00805f9b34fb", "0000ffe2-0000-1000-8000-00805f9b34fb", "0000fff4-0000-1000-8000-00805f9b34fb", "0000fff4-0000-1000-8000-00805f9b34fb"]
TURN_ON_CMD = [[0x7e, 0x00, 0x04, 0xf0, 0x00, 0x01, 0xff, 0x00, 0xef],[0x7e, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0xef], bytearray([0x7e, 0x07, 0x83]),[0x7e, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0xef]]
TURN_OFF_CMD = [[0x7e, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0x00, 0xef], [0x7e, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0x00, 0xef], bytearray([0x7e, 0x04, 0x04]), [0x7e, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0x00, 0xef]]

DEFAULT_ATTEMPTS = 3
DISCONNECT_DELAY = 120
Expand Down Expand Up @@ -114,9 +114,9 @@ def __init__(self, address, reset: bool, hass) -> None:
self._reset = reset
self._hass = hass
self._device: BLEDevice | None = None
self._device = bluetooth.async_ble_device_from_address(self._hass, address, connectable=True)
self._device = bluetooth.async_ble_device_from_address(self._hass, address)
if not self._device:
raise ConfigEntryNotReady(f"Couldn't find a nearby device with address: {address}")
raise ConfigEntryNotReady(f"You need to add bluetooth integration (https://www.home-assistant.io/integrations/bluetooth) or couldn't find a nearby device with address: {address}")
self._connect_lock: asyncio.Lock = asyncio.Lock()
self._client: BleakClientWithServiceCache | None = None
self._disconnect_timer: asyncio.TimerHandle | None = None
Expand Down
4 changes: 2 additions & 2 deletions custom_components/elkbledom/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def brightness(self):
if self._instance._rgb_color:
return max(self._instance.rgb_color)

return None
return 250

@property
def is_on(self) -> Optional[bool]:
Expand Down Expand Up @@ -135,7 +135,7 @@ async def async_turn_on(self, **kwargs: Any) -> None:
if not self.is_on:
await self._instance.turn_on()
if self._instance.reset:
LOGGER.debug("Change color to white, some error with other infrared control interact")
LOGGER.debug("Change color to white to reset led strip when other infrared control interact")
await self._instance.set_color(self._transform_color_brightness((255, 255, 255), 250))

if ATTR_BRIGHTNESS in kwargs and kwargs[ATTR_BRIGHTNESS] != self.brightness and self.rgb_color != None:
Expand Down
33 changes: 17 additions & 16 deletions custom_components/elkbledom/manifest.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"domain": "elkbledom",
"name": "ElkBLEDOM",
"bluetooth": [
{ "local_name": "ELK-BLE*" },
{ "local_name": "MELK*" },
{ "local_name": "LEDBLE*" }
],
"codeowners": ["@dave-code-ruiz"],
"config_flow": true,
"dependencies": ["bluetooth"],
"documentation": "https://github.com/dave-code-ruiz/elkbledom",
"iot_class": "local_polling",
"issue_tracker": "https://github.com/dave-code-ruiz/elkbledom/issues",
"requirements": ["bleak-retry-connector>=1.17.1","bleak>=0.17.0"],
"version": "1.0.0"
}
"domain": "elkbledom",
"name": "ElkBLEDOM",
"bluetooth": [
{ "local_name": "ELK-BULB*" },
{ "local_name": "ELK-BLE*" },
{ "local_name": "MELK*" },
{ "local_name": "LEDBLE*" }
],
"codeowners": ["@dave-code-ruiz"],
"config_flow": true,
"dependencies": ["bluetooth"],
"documentation": "https://github.com/dave-code-ruiz/elkbledom",
"iot_class": "local_polling",
"issue_tracker": "https://github.com/dave-code-ruiz/elkbledom/issues",
"requirements": ["bleak-retry-connector>=1.17.1","bleak>=0.17.0"],
"version": "1.0.2"
}
88 changes: 44 additions & 44 deletions custom_components/elkbledom/translations/fr.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
{
"config": {
"step": {
"user": {
"data": {
"mac": "Adresse MAC Bluetooth",
"name": "Nom"
},
"title": "Sélectionner une lumière Elkbledom."
},
"validate": {
"data": {
"retry": "Réessayer de se connecter ?",
"flicker": "La lumière à-t-elle clignoté ?"
},
"title": "Valider la connexion"
},
"manual": {
"data": {
"mac": "Adresse MAC Bluetooth",
"name": "Nom"
},
"title": "Entrer une adresse MAC Bluetooth"
}
},
"error": {
"connect": "Echec de la connexion à Elkbledom"
},
"abort": {
"cannot_validate": "Echec de validation de la lumière Elkbledom",
"cannot_connect": "Echec de la connexion à Elkbledom"
}
},
"options": {
"step": {
"user": {
"data": {
"reset": "Réinitialiser la couleur à l'allumage"
}
}
}
},
"title": "Elkbledom"
}
{
"config": {
"step": {
"user": {
"data": {
"mac": "Adresse MAC Bluetooth",
"name": "Nom"
},
"title": "Sélectionner une lumi?re Elkbledom."
},
"validate": {
"data": {
"retry": "Réessayer de se connecter ?",
"flicker": "La lumi?re ?-t-elle clignoté ?"
},
"title": "Valider la connexion"
},
"manual": {
"data": {
"mac": "Adresse MAC Bluetooth",
"name": "Nom"
},
"title": "Entrer une adresse MAC Bluetooth"
}
},
"error": {
"connect": "Echec de la connexion ? Elkbledom"
},
"abort": {
"cannot_validate": "Echec de validation de la lumi?re Elkbledom",
"cannot_connect": "Echec de la connexion ? Elkbledom"
}
},
"options": {
"step": {
"user": {
"data": {
"reset": "Réinitialiser la couleur ? l'allumage"
}
}
}
},
"title": "Elkbledom"
}
88 changes: 44 additions & 44 deletions custom_components/elkbledom/translations/pl.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
{
"config": {
"step": {
"user": {
"data": {
"mac": "Adres MAC Bluetooth",
"name": "Nazwa"
},
"title": "Wybierz światło Elkbledom. Upewnij się, że masz je w zasięgu wzroku w celu weryfikacji."
},
"validate": {
"data": {
"retry": "Powtórzyć połączenie weryfikacyjne?",
"flicker": "Czy światło migało?"
},
"title": "Weryfikacja połączenia Elkbledom"
},
"manual": {
"data": {
"mac": "Adres MAC Bluetooth",
"name": "Nazwa"
},
"title": "Wprowadź adres MAC Bluetooth"
}
},
"error": {
"connect": "Nie można nawiązać połącznenia do światła Elkbledom"
},
"abort": {
"cannot_validate": "Nie można zweryfikować światła Elkbledom",
"cannot_connect": "Nie można połączyć się ze światłem Elkbledom"
}
},
"options": {
"step": {
"user": {
"data": {
"reset": "Zresetuj kolor gdy LED włączy się"
}
}
}
},
"title": "Elkbledom"
}
{
"config": {
"step": {
"user": {
"data": {
"mac": "Adres MAC Bluetooth",
"name": "Nazwa"
},
"title": "Wybierz światło Elkbledom. Upewnij się, że masz je w zasięgu wzroku w celu weryfikacji."
},
"validate": {
"data": {
"retry": "Powtórzyć połączenie weryfikacyjne?",
"flicker": "Czy światło migało?"
},
"title": "Weryfikacja połączenia Elkbledom"
},
"manual": {
"data": {
"mac": "Adres MAC Bluetooth",
"name": "Nazwa"
},
"title": "Wprowadź adres MAC Bluetooth"
}
},
"error": {
"connect": "Nie można nawiązać połącznenia do światła Elkbledom"
},
"abort": {
"cannot_validate": "Nie można zweryfikować światła Elkbledom",
"cannot_connect": "Nie można połączyć się ze światłem Elkbledom"
}
},
"options": {
"step": {
"user": {
"data": {
"reset": "Zresetuj kolor gdy LED włączy się"
}
}
}
},
"title": "Elkbledom"
}

0 comments on commit 96e389b

Please sign in to comment.