I’ve gone and brought my self a home alarm that has rf remote, rf door senors and rf remotes. This alarm can be controled via Tuya.
I first tried the new V2 Intergration of Tuya and found confirmed my device was not supported.
I then tried LocalTuya and although my device isn’t supported I might be able to modifly the switch object to work.
Looking at Tuya and the Alarm it appears when the Alarm is set it sends the command “arm” to id 1 and then to disarm it send “disarmed”.
I made a small change to the switch.py in local Tuya from
async def async_turn_on(self, **kwargs):
"""Turn Tuya switch on."""
await self._device.set_dp(True, self._dp_id)
async def async_turn_off(self, **kwargs):
"""Turn Tuya switch off."""
await self._device.set_dp(False, self._dp_id)
to
async def async_turn_on(self, **kwargs):
"""Turn Tuya switch on."""
await self._device.set_dp("arm", self._dp_id)
async def async_turn_off(self, **kwargs):
"""Turn Tuya switch off."""
await self._device.set_dp("disarmed", self._dp_id)
and that seems to send the command and the command does take but it is only a small part of the soultion.
What is really failing at the moment is the switch updating its status and showing correctly on the dashboard (keeps showing as turned off).
I have tried to modify the function
def status_updated(self):
"""Device status was updated."""
self._state = self.dps(self._dp_id)
But have had no joy.
Even if I get this working I have then stuffed up the script for all other switches
So question time:
Is there a better way to do this.
Are there simple documents to get an understanding of how to write a Integration so I can work out where I need to change the code to add another component into the LocalTyua Integration.
Is there a smart way to do this?