Edit: Update - I set anonymous to true from false and can now see the switch in HA. They are switched off by default, whenever I switch them on, they switch back off again.
MQTT Switch payload - https://i.imgur.com/KmCkNrw.png
Tuya Gateway log - https://pastebin.com/iJFw0ypZ
Listening to topic shows this - https://i.imgur.com/V4jq87P.png
2020-09-10 22:40:38,302 ERROR (Thread-7) [tuyaface.tuyaclient] (192.168.86.62) Unexpected exception
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/tuyaface/tuyaclient.py", line 194, in run
result = command(*args)
File "/usr/lib/python3.8/site-packages/tuyaface/tuyaclient.py", line 217, in _status
status_reply, all_replies = _status(self.device)
File "/usr/lib/python3.8/site-packages/tuyaface/__init__.py", line 268, in _status
new_replies = list(reply for reply in _receive_replies(device, 1))
File "/usr/lib/python3.8/site-packages/tuyaface/__init__.py", line 268, in <genexpr>
new_replies = list(reply for reply in _receive_replies(device, 1))
File "/usr/lib/python3.8/site-packages/tuyaface/__init__.py", line 406, in _receive_replies
raise ex
File "/usr/lib/python3.8/site-packages/tuyaface/__init__.py", line 401, in _receive_replies
for reply in _process_raw_reply(device, data):
File "/usr/lib/python3.8/site-packages/tuyaface/__init__.py", line 169, in _process_raw_reply
payload = aescipher.decrypt(device["localkey"], data, False)
File "/usr/lib/python3.8/site-packages/tuyaface/aescipher.py", line 22, in decrypt
return _unpad(raw).decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa3 in position 0: invalid start byte
Hello. First of all, thank you for creating the Tuya Gateway. I’m trying to move from Tuya Local and I’m struggling a little. I’m hoping you can help me figure out what I’m doing wrong.
What do I want?
I have a tuya smart plug (switch) which I’d like to use via Home Assistant
Problem
I don’t see a switch in Home Assistant > Devices or Entities
Setup
HA - https://i.imgur.com/7EDSvHT.png
HA log -
2020-09-10 22:00:41 ERROR (MainThread) [homeassistant.components.switch] Error while setting up mqtt platform for switch
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 192, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 301, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 472, in _async_add_entity
await entity.async_added_to_hass()
File "/usr/src/homeassistant/homeassistant/components/mqtt/switch.py", line 135, in async_added_to_hass
await self._subscribe_topics()
File "/usr/src/homeassistant/homeassistant/components/mqtt/switch.py", line 183, in _subscribe_topics
self._sub_state = await subscription.async_subscribe_topics(
File "/usr/src/homeassistant/homeassistant/components/mqtt/subscription.py", line 93, in async_subscribe_topics
await requested.resubscribe_if_necessary(hass, current)
File "/usr/src/homeassistant/homeassistant/components/mqtt/subscription.py", line 48, in resubscribe_if_necessary
self.unsubscribe_callback = await mqtt.async_subscribe(
File "/usr/src/homeassistant/homeassistant/components/mqtt/__init__.py", line 416, in async_subscribe
async_remove = await hass.data[DATA_MQTT].async_subscribe(
KeyError: 'mqtt'
-
I have installed Mosquito Broker via add-on store.
Config - https://i.imgur.com/iBzSeFz.png
Here’s the log - https://pastebin.com/mLjkmgTh -
I’ve installed Tuya Gateway via https://github.com/sjthespian/addon-tuyagateway
Config - https://i.imgur.com/zdffMOB.png
Here’s the log - https://pastebin.com/B9EMTAFk -
Here are my Gismo Caster Settings -
https://i.imgur.com/Pehk66H.png
Gismo Model
https://i.imgur.com/7Lgi3pR.png
Gismo
https://i.imgur.com/sE9hEbS.png -
HA configuration.yaml -
https://i.imgur.com/gGRZpI8.png
Things I’ve tried
-
mosquitto_pub -t tuya/bf57555ad780d86beb4h8c/1/command -m ON
output -Error: Address not available
-
I’ve also tried adding the below code to config.yaml but that just adds a switch and says it’s unavailable
switch:
- platform: mqtt
unique_id: test
name: "test"
state_topic: "tuya/bf57555ad780d86beb4h8c/#"
payload_on: "ON"
payload_off: "OFF"
state_on: "ON"
state_off: "OFF"
optimistic: false
qos: 0
retain: true
@Tradeface Could you be kind enough to let me know what I’m doing wrong here?