Open amorfinv opened 1 month ago
Here's another person interested in making this integration work. I've looked for other alternatives but I can't find anything compatible with my air conditioning, which used to work perfectly with the TFIAC integration.
Any compatible solution please? I don't mind replacing the wifi module with an ESP or something like that, but I can't find anything compatible.
Thanks
This project works with my air conditioner, with an esp01 and the hw580 board https://github.com/lNikazzzl/tcl_ac_esphome
That's really strange. pytfiac
has a dependency on the package which creates an "inteface for Tellstick Net device" just to use 2 utility functions to work with UDP in async way.
I agree with @amorfinv. It's better to completely remove this dependency.
Could ask the tellsticknet author to be a contributor so they also get attribution since it's their code.
It can potentially take months and years :). I suggest to use a package which was created to help making UDP async. For example this one https://github.com/eerimoq/asyncudp. Or maybe modern Python versions already have better support for async UDP.
Here is an example to send a UDP packet and receive a response, that ChatGPT provided for me w/o using any deps:
import asyncio
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
async def send_udp_packet():
loop = asyncio.get_running_loop()
# Define the UDP target address and message
target_address = ('127.0.0.1', 9999)
message = b'Hello, UDP server!'
# Create a UDP socket
transport, protocol = await loop.create_datagram_endpoint(
lambda: asyncio.DatagramProtocol(),
remote_addr=target_address
)
# Send the message
logger.info(f"Sending UDP packet to {target_address}")
transport.sendto(message)
# Wait for response with a timeout of 5 seconds
try:
response = await asyncio.wait_for(loop.sock_recv(transport.get_extra_info('socket'), 1024), timeout=5)
logger.info(f"Received response: {response.decode()}")
except asyncio.TimeoutError:
logger.error("No response received within 5 seconds.")
finally:
transport.close()
async def main():
await send_udp_packet()
if __name__ == '__main__':
asyncio.run(main())
@fredrike what do you think?
Hi, I noticed that in the home assistant release notes for 2024.10 there was a call for help to solve the dependencies issues with this library.
It appears that the calls to
tellsticknet
are just two UDP functions. There seems to be no reason to depend on the old mqtt library. Is that correct?Maybe it is possible to reimplement the functions directly in this library.
Could ask the
tellsticknet
author to be a contributor so they also get attribution since it's their code.