Closes #2
Add Airsend 1-button mapping to HA ButtonEntity instead of SwitchEntity
This commit is contained in:
@@ -32,7 +32,7 @@ async def async_setup_platform(hass : HomeAssistant, config : ConfigType, async_
|
||||
if discovery_info is None:
|
||||
return
|
||||
for name, options in discovery_info.items():
|
||||
if options['type'] == 4096 or options['type'] == 4097:
|
||||
if options['type'] == 4097:
|
||||
id = ""
|
||||
apiKey = ""
|
||||
spurl = ""
|
||||
@@ -115,22 +115,16 @@ class AirSendSwitch(SwitchEntity):
|
||||
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
command = "6"
|
||||
note = self._note
|
||||
if self._type == 4097:
|
||||
command = "1"
|
||||
note = {"method":1,"type":0,"value": "ON"}
|
||||
command = "1"
|
||||
note = {"method":1,"type":0,"value": "ON"}
|
||||
url = "https://airsend.cloud/device/"+str(self._id)+"/command/"+command+"/"
|
||||
payload = '{"wait": true, "channel":'+json.dumps(self._channel)+', "thingnotes":{"notes":['+json.dumps(note)+']}}'
|
||||
self._action(url, payload, True)
|
||||
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device off."""
|
||||
command = "6"
|
||||
note = self._note
|
||||
if self._type == 4097:
|
||||
command = "0"
|
||||
note = {"method":1,"type":0,"value": "OFF"}
|
||||
command = "0"
|
||||
note = {"method":1,"type":0,"value": "OFF"}
|
||||
url = "https://airsend.cloud/device/"+str(self._id)+"/command/"+command+"/"
|
||||
payload = '{"wait": true, "channel":'+json.dumps(self._channel)+', "thingnotes":{"notes":['+json.dumps(note)+']}}'
|
||||
self._action(url, payload, False)
|
||||
|
||||
Reference in New Issue
Block a user