Skip to content

Commit 6070759

Browse files
committed
v0.2.9
1 parent 0815145 commit 6070759

File tree

8 files changed

+137
-137
lines changed

8 files changed

+137
-137
lines changed

custom_components/ledfxrm/__init__.py

+56-56
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
6464
thestart = entry.data.get(CONF_START)
6565
thestop = entry.data.get(CONF_STOP)
6666
thescan = entry.data.get(CONF_SCAN_INTERVAL)
67-
thesubdevices = entry.data.get(CONF_SHOW_SUBDEVICES)
67+
thesubdisplays = entry.data.get(CONF_SHOW_SUBDEVICES)
6868
theblade_light = entry.data.get(CONF_SHOW_BLADELIGHT)
6969
thestart_method = entry.data.get(CONF_START_METHOD)
7070
thestart_body = entry.data.get(CONF_START_BODY)
@@ -78,7 +78,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
7878
thestart,
7979
thestop,
8080
thescan,
81-
thesubdevices,
81+
thesubdisplays,
8282
theblade_light,
8383
thestart_method,
8484
thestart_body,
@@ -113,7 +113,7 @@ def __init__(
113113
theport,
114114
thestart,
115115
thestop,
116-
thesubdevices,
116+
thesubdisplays,
117117
theblade_light,
118118
thestart_method,
119119
thestart_body,
@@ -126,10 +126,10 @@ def __init__(
126126
self.thestop = thestop
127127
self.connected = False
128128
self.effect = "off"
129-
self.thesubdevices = thesubdevices
129+
self.thesubdisplays = thesubdisplays
130130
self.theblade_light = theblade_light
131-
self.devicestates = {}
132-
self.devices = {}
131+
self.displaystates = {}
132+
self.displays = {}
133133
self.virtuals = {}
134134
self.thestart_method = thestart_method
135135
self.thestart_body = thestart_body
@@ -144,11 +144,11 @@ async def update(self):
144144
url4 = "http://" + self.thehost + ":" + str(self.theport) + "/api/virtuals"
145145
yz = {}
146146
rest_info = {}
147-
rest_devices = {}
147+
rest_displays = {}
148148
rest_scenes = {}
149149
rest_virtuals = {}
150150
yz["rest_info"] = {}
151-
yz["rest_devices"] = {}
151+
yz["rest_displays"] = {}
152152
yz["rest_scenes"] = {}
153153
yz["rest_virtuals"] = {}
154154

@@ -170,30 +170,30 @@ async def update(self):
170170
return {}
171171

172172
try:
173-
async with session.get(url2, ssl=False) as resp_devices:
174-
if resp_devices.status == 200:
175-
rest_devices = await resp_devices.json()
176-
yz["rest_devices"] = rest_devices
177-
self.devices = yz["rest_devices"]
178-
if len(self.devicestates) == 0:
179-
for k in rest_devices["displays"]:
173+
async with session.get(url2, ssl=False) as resp_displays:
174+
if resp_displays.status == 200:
175+
rest_displays = await resp_displays.json()
176+
yz["rest_displays"] = rest_displays
177+
self.displays = yz["rest_displays"]
178+
if len(self.displaystates) == 0:
179+
for k in rest_displays["displays"]:
180180
if (
181-
len(rest_devices["displays"][k].get("effect", {}))
181+
len(rest_displays["displays"][k].get("effect", {}))
182182
> 0
183183
):
184-
effect = rest_devices["displays"][k].get("effect")
184+
effect = rest_displays["displays"][k].get("effect")
185185
power = True
186186
else:
187187

188188
effect = {}
189189
power = False
190-
self.devicestates[k] = {
190+
self.displaystates[k] = {
191191
"power": power,
192192
"effect": effect,
193193
}
194194
else:
195195
logging.warning(
196-
"CANT CONNECT TO LEDFX - DEVICES: %s", resp_devices.status
196+
"CANT CONNECT TO LEDFX - DEVICES: %s", resp_displays.status
197197
)
198198

199199
except aiohttp.ClientConnectorError as e:
@@ -230,28 +230,28 @@ async def update(self):
230230
# rest_info = await resp.json()
231231
# yz["rest_info"] = rest_info
232232

233-
# async with session.get(url2, ssl=False) as resp_devices:
234-
# rest_devices = await resp_devices.json()
235-
# yz["rest_devices"] = rest_devices
236-
# self.devices = yz["rest_devices"]
237-
# # logging.warning("INTERNAL STATES b4: %s", self.devicestates)
238-
# if len(self.devicestates) == 0:
239-
# for k in rest_devices["devices"]:
233+
# async with session.get(url2, ssl=False) as resp_displays:
234+
# rest_displays = await resp_displays.json()
235+
# yz["rest_displays"] = rest_displays
236+
# self.displays = yz["rest_displays"]
237+
# # logging.warning("INTERNAL STATES b4: %s", self.displaystates)
238+
# if len(self.displaystates) == 0:
239+
# for k in rest_displays["displays"]:
240240
# # logging.warning("NOWWW: %s", k)
241-
# # logging.warning("THENN: %s", rest_devices['devices'][k])
242-
# if len(rest_devices["devices"][k].get("effect", {})) > 0:
243-
# # logging.warning("GOT EFFECT FROM LEDFX: %s", rest_devices['devices'][k].get('effect'))
244-
# effect = rest_devices["devices"][k].get("effect")
241+
# # logging.warning("THENN: %s", rest_displays['displays'][k])
242+
# if len(rest_displays["displays"][k].get("effect", {})) > 0:
243+
# # logging.warning("GOT EFFECT FROM LEDFX: %s", rest_displays['displays'][k].get('effect'))
244+
# effect = rest_displays["displays"][k].get("effect")
245245
# power = True
246246
# else:
247247

248248
# effect = {}
249249
# power = False
250-
# self.devicestates[k] = {
250+
# self.displaystates[k] = {
251251
# "power": power,
252-
# "effect": effect, # self.devicestates[k].get('effect', {})
252+
# "effect": effect, # self.displaystates[k].get('effect', {})
253253
# }
254-
# # logging.warning("INTERNAL STATES after: %s", self.devicestates)
254+
# # logging.warning("INTERNAL STATES after: %s", self.displaystates)
255255

256256
# async with session.get(url3, ssl=False) as resp_scenes:
257257
# rest_scenes = await resp_scenes.json()
@@ -262,10 +262,10 @@ async def update(self):
262262

263263
return {
264264
"info": rest_info,
265-
"devices": rest_devices,
265+
"displays": rest_displays,
266266
"virtuals": rest_virtuals,
267267
"scenes": rest_scenes,
268-
"show_subdevices": self.thesubdevices,
268+
"show_subdisplays": self.thesubdisplays,
269269
}
270270

271271
async def async_set_transition_time(self, time):
@@ -345,13 +345,13 @@ async def async_set_scene(self, effect):
345345
return None
346346

347347
async def async_device_off(self, state):
348-
# logging.warning('DEVICE OFF internal --- %s --- %s', state, self.devicestates[state].get('effect'))
348+
# logging.warning('DEVICE OFF internal --- %s --- %s', state, self.displaystates[state].get('effect'))
349349
url4 = (
350350
"http://"
351351
+ self.thehost
352352
+ ":"
353353
+ str(self.theport)
354-
+ "/api/devices/"
354+
+ "/api/displays/"
355355
+ state
356356
+ "/effects"
357357
)
@@ -361,24 +361,24 @@ async def async_device_off(self, state):
361361
async with session.get(url4, ssl=False) as get_effect:
362362
testing = await get_effect.json()
363363
if testing["effect"] != {}:
364-
self.devicestates[state]["effect"] = testing["effect"]
365-
# logging.warning("Turning Off, found effect: %s", self.devicestates[state].get('effect'))
364+
self.displaystates[state]["effect"] = testing["effect"]
365+
# logging.warning("Turning Off, found effect: %s", self.displaystates[state].get('effect'))
366366
async with session.delete(url4, ssl=False) as del_effect:
367367
await del_effect.json()
368368
# else:
369369
# logging.warning("Turning Off, No effect:")
370370

371-
self.devicestates[state]["power"] = False
371+
self.displaystates[state]["power"] = False
372372
return None
373373

374374
async def async_device_on(self, state):
375-
# logging.warning('DEVICE ON internal --- %s --- %s', state, self.devicestates[state].get('effect'))
375+
# logging.warning('DEVICE ON internal --- %s --- %s', state, self.displaystates[state].get('effect'))
376376
url4 = (
377377
"http://"
378378
+ self.thehost
379379
+ ":"
380380
+ str(self.theport)
381-
+ "/api/devices/"
381+
+ "/api/displays/"
382382
+ state
383383
+ "/effects"
384384
)
@@ -389,10 +389,10 @@ async def async_device_on(self, state):
389389
testing = await get_effect.json()
390390
if testing["effect"] != {}:
391391
# logging.warning("Turning on, found effect: %s", testing['effect'])
392-
self.devicestates[state]["effect"] = testing["effect"]
392+
self.displaystates[state]["effect"] = testing["effect"]
393393

394-
# payload = {'config': self.devicestates[state].get('effect').get('config')}
395-
payload = self.devicestates[state].get("effect")
394+
# payload = {'config': self.displaystates[state].get('effect').get('config')}
395+
payload = self.displaystates[state].get("effect")
396396

397397
if payload is None or payload == {}:
398398
payload = {
@@ -416,7 +416,7 @@ async def async_device_on(self, state):
416416
# logging.warning("Setting Effect, %s", payload)
417417
async with session.post(url4, json=payload, ssl=False) as set_effect:
418418
await set_effect.json()
419-
self.devicestates[state]["power"] = True
419+
self.displaystates[state]["power"] = True
420420
return None
421421

422422
async def async_virtual_off(self, virtual):
@@ -430,9 +430,9 @@ async def async_virtual_off(self, virtual):
430430
for key in c:
431431
# logging.warning(
432432
# "BLADE OFF internal --- %s --- %s --- %s",
433-
# self.devices.get("devices").get(key).get("config").get("name"),
434-
# self.devices.get("devices").get(key).get("config").get("ip_address"),
435-
# self.devices.get("devices").get(key).get("config").get("pixel_count"),
433+
# self.displays.get("displays").get(key).get("config").get("name"),
434+
# self.displays.get("displays").get(key).get("config").get("ip_address"),
435+
# self.displays.get("displays").get(key).get("config").get("pixel_count"),
436436
# )
437437
for i in range(key.get("used_pixel")):
438438

@@ -521,7 +521,7 @@ def __init__(
521521
theblade_light,
522522
thestop,
523523
thescan,
524-
thesubdevices,
524+
thesubdisplays,
525525
thestart_method,
526526
thestart_body,
527527
thestop_method,
@@ -535,7 +535,7 @@ def __init__(
535535
self.thestop = thestop
536536
self.thestart = thestart
537537
self.thescan = thescan
538-
self.thesubdevices = thesubdevices
538+
self.thesubdisplays = thesubdisplays
539539
self.theblade_light = theblade_light
540540
self.thestart_method = thestart_method
541541
self.thestart_body = thestart_body
@@ -547,7 +547,7 @@ def __init__(
547547
theport,
548548
thestart,
549549
thestop,
550-
thesubdevices,
550+
thesubdisplays,
551551
theblade_light,
552552
thestart_method,
553553
thestart_body,
@@ -564,17 +564,17 @@ async def _async_update_data(self):
564564
# logging.warning('SCAN_INTERVAL_CHECK %s', self.thescan)
565565
data = await self.api.update()
566566
scenes = {}
567-
devices = {}
567+
displays = {}
568568
virtuals = {}
569569
# logging.warning("UPDATING %s", data)
570570
if data != {}:
571571

572572
scenes = data.get("scenes").get("scenes")
573-
devices = data.get("devices").get("devices")
573+
displays = data.get("displays").get("displays")
574574
if scenes != {}:
575575
# logging.warning("UPDATING WTF %s", data)
576576
self.scenes = scenes
577-
self.devices = devices
577+
self.displays = displays
578578
self.number_scenes = len(scenes)
579579
self.lost = False
580580
self.connected = True
@@ -605,7 +605,7 @@ async def _async_update_data(self):
605605
return {
606606
"info": {"name": "Not Ready", "version": "1.0"},
607607
"scenes": {"scenes": {}},
608-
"devices": {"devices": {}},
608+
"displays": {"displays": {}},
609609
"virtuals": {"virtuals": {}},
610610
}
611611

custom_components/ledfxrm/binary_sensor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
from custom_components.ledfxrm.entity import LedfxrmEntity
1111

1212

13-
async def async_setup_entry(hass, entry, async_add_devices):
13+
async def async_setup_entry(hass, entry, async_add_displays):
1414
"""Setup binary_sensor platform."""
1515
coordinator = hass.data[DOMAIN][entry.entry_id]
16-
async_add_devices([LedfxrmBinarySensor(coordinator, entry)])
16+
async_add_displays([LedfxrmBinarySensor(coordinator, entry)])
1717

1818

1919
class LedfxrmBinarySensor(LedfxrmEntity, BinarySensorEntity ):

custom_components/ledfxrm/const.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
NAME = "LedFx ReMote"
44
DOMAIN = "ledfxrm"
55
DOMAIN_DATA = f"{DOMAIN}_data"
6-
VERSION = "0.2.6"
6+
VERSION = "0.2.9"
77
MANUFACTURER = "YeonV"
88

99
ISSUE_URL = "https://github.com/YeonV/ledfxrm/issues"
@@ -37,7 +37,7 @@
3737
CONF_STOP = "stop"
3838
CONF_ADVANCED = "advanced"
3939
CONF_SCAN_INTERVAL = "scan_interval"
40-
CONF_SHOW_SUBDEVICES = "show_subdevices"
40+
CONF_SHOW_SUBDEVICES = "show_subdisplays"
4141
CONF_SHOW_BLADELIGHT = "show_blade_light"
4242
CONF_START_METHOD = "start_method"
4343
CONF_STOP_METHOD = "stop_method"

custom_components/ledfxrm/light.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,26 @@
3232
from typing import Any, Dict, Optional
3333

3434

35-
async def async_setup_entry(hass, entry, async_add_devices):
35+
async def async_setup_entry(hass, entry, async_add_displays):
3636
"""Setup sensor platform."""
3737
coordinator = hass.data[DOMAIN][entry.entry_id]
38-
devicenames = coordinator.data.get("devices").get("devices")
38+
devicenames = coordinator.data.get("displays").get("displays")
3939
virtuals = coordinator.data.get("virtuals").get("virtuals").get("list")
4040
# logging.warning("YEEES2: %s", virtuals)
4141
test = entry.data.get(CONF_SHOW_SUBDEVICES)
4242
test2 = entry.data.get(CONF_SHOW_BLADELIGHT)
4343
if test is True:
4444
for k in devicenames:
45-
async_add_devices(
45+
async_add_displays(
4646
[LedfxrmChildLight(coordinator, entry, k, devicenames[k]["config"])]
4747
)
4848

4949
if test2 is True:
50-
async_add_devices([LedfxrmLight(coordinator, entry)])
50+
async_add_displays([LedfxrmLight(coordinator, entry)])
5151
for k in virtuals:
52-
async_add_devices([LedfxrmVirtualsLight(coordinator, entry, k)])
52+
async_add_displays([LedfxrmVirtualsLight(coordinator, entry, k)])
5353
else:
54-
async_add_devices([LedfxrmLight(coordinator, entry)])
54+
async_add_displays([LedfxrmLight(coordinator, entry)])
5555

5656

5757
class LedfxrmLight(LedfxrmEntity, LightEntity):
@@ -112,7 +112,7 @@ def effect_list(self):
112112
def device_state_attributes(self) -> Optional[Dict[str, Any]]:
113113
"""Return the state attributes of the entity."""
114114
scenenames = self.coordinator.data.get("scenes").get("scenes")
115-
devicenames = self.coordinator.data.get("devices").get("devices")
115+
devicenames = self.coordinator.data.get("displays").get("displays")
116116
pixels = 0
117117
for k in devicenames:
118118
pixels = pixels + devicenames[k]["config"].get("pixel_count")
@@ -203,22 +203,22 @@ def effect_list(self):
203203
@property
204204
def device_state_attributes(self) -> Optional[Dict[str, Any]]:
205205
"""Return the state attributes of the entity."""
206-
# logging.warning("OMMMMG: %s ", self.coordinator.api.devicestates)
206+
# logging.warning("OMMMMG: %s ", self.coordinator.api.displaystates)
207207
if self.deviceconfig == {}:
208208
return {"status": "error"}
209209
return {
210210
"IP": self.deviceconfig["ip_address"],
211211
"Pixels": self.deviceconfig["pixel_count"],
212212
"Refresh Rate": self.deviceconfig["refresh_rate"],
213-
"Mode": self.coordinator.api.devicestates[self.devicename]["effect"].get(
213+
"Mode": self.coordinator.api.displaystates[self.devicename]["effect"].get(
214214
"name", "OFF"
215215
),
216216
}
217217

218218
@property
219219
def is_on(self):
220220
"""Return true if the light is on."""
221-
return self.coordinator.api.devicestates[self.devicename]["power"]
221+
return self.coordinator.api.displaystates[self.devicename]["power"]
222222

223223

224224
class LedfxrmVirtualsLight(LedfxrmLight):
@@ -318,5 +318,5 @@ def device_state_attributes(self) -> Optional[Dict[str, Any]]:
318318
@property
319319
def is_on(self):
320320
"""Return true if the light is on."""
321-
# return self.coordinator.api.devicestates[self.devicename]["power"]
321+
# return self.coordinator.api.displaystates[self.devicename]["power"]
322322
return True

0 commit comments

Comments
 (0)