Tuyagateway do not publish state topic
I think i have GC configured well, all the devices appear fine HA, but TG do not publish state topic. All the other topics are well published, and updated, except this one.
Did i miss something ?
state is only published on state change
Well, it make sense :) I did publish messages into TG's command topic. It's actually works, but no state update so far.
HA Discovery conf :
{
"qos": 0,
"name": "Smart led",
"avty_t": "tuya/bff590a2c25cf0a2bazufd/availability",
"pl_avail": "online",
"pl_not_avail": "offline",
"bri_cmd_t": "~brightness_command",
"bri_stat_t": "~brightness_state",
"clr_temp_cmd_t": "~color_temp_command",
"clr_temp_stat_t": "~color_temp_state",
"cmd_t": "~command",
"pl_off": "OFF",
"pl_on": "ON",
"fx_cmd_t": "~effect_command",
"fx_stat_t": "~effect_state",
"hs_cmd_t": "~hs_command",
"hs_stat_t": "~hs_state",
"json_attr_t": "~attributes",
"rgb_cmd_t": "~rgb_command",
"rgb_stat_t": "~rgb_state",
"whit_val_cmd_t": "~white_value_command",
"whit_val_stat_t": "~white_value_state",
"xy_cmd_t": "~xy_command",
"xy_stat_t": "~xy_state",
"stat_t": "~state",
"uniq_id": "bff590a2c25cf0a2bazufd_1",
"device": {
"identifiers": ["bff590a2c25cf0a2bazufd"],
"name": "Smart led",
"model": "Tuya",
"sw_version": "1.0.0",
"manufacturer": "GismoCaster",
"via_device": "Smart led"
},
"~": "tuya/bff590a2c25cf0a2bazufd/1/"
}
Tuya discovery config :
{
"name": "Smart led",
"deviceid": "bff590a2c25cf0a2bazufd",
"localkey": "abcdef",
"ip": "192.168.0.106",
"ha_discovery": true,
"tuya_discovery": true,
"protocol": "3.3",
"pref_status_cmd": 10,
"dps": [{
"key": 1,
"name": "ON/OFF",
"type_value": "bool",
"minimal": 0.0,
"maximal": 255.0,
"device_component": "light",
"device_topic": "state_topic"
}]
}
this is the tuya topic, where state topic should be:

You correctly unmapped the state values. TG also reads the HA config to compose the message. On top of mind it doesn't fallback to pl_off/pl_on when the state values aren't found. So perhaps it doesn't know what the payload should be. Have to check, probably a bug.
tuyagateway/tuyagateway/transform/homeassistant.py
l:170 calls _get_topic_value(output_topic, self._state_data)
needs fallback to pl_off/pl_on for state_topic
It's indeed working with a switch device, which use the standard GC state topic.
Dev branch has some updated code. Can you check if this solves the problem.
ref
topic = self._full_topic(output_topic["default_value"])["full"]
payload = _get_topic_value(output_topic, self._state_data)
if payload is None and self.data_point["device_topic"] == "state_topic":
fallback_topic = self._get_fallback_topic(
self.data_point["device_topic"]
)
payload = _get_topic_value(fallback_topic, self._state_data)
self._command_value = payload
Tested OK, but not with dev branch's HEAD. I had to use the latest working version -> tags/v2.0.1 and cherry pick this commit in order to get it working.
dev branch head's result in TG to always publish devices as offline. I did not perform extensive testing, but i'll open another issue for that :)