Announcement

Collapse
No announcement yet.

Is it possible to move Tuya local control devices to a separate VLAN?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • RGMessick
    replied
    Originally posted by windracer View Post
    Sorry to bump this thread but just wondering when this will be added to the plug-in? I'm running 4.0.39.0 BETA but still don't have local control of that fan controller.

    Thanks!
    +1

    Leave a comment:


  • avpman
    replied
    Originally posted by windracer View Post
    Sorry to bump this thread but just wondering when this will be added to the plug-in? I'm running 4.0.39.0 BETA but still don't have local control of that fan controller.

    Thanks!
    +1, thanks!

    Leave a comment:


  • windracer
    replied
    Originally posted by spud View Post
    It doesn't work because your device uses a new API version 3.4, with some new message types and encryption. The plugin only supports 3.1 and 3.3 versions. I will create an internal enhancement request to support 3.4.
    Sorry to bump this thread but just wondering when this will be added to the plug-in? I'm running 4.0.39.0 BETA but still don't have local control of that fan controller.

    Thanks!

    Leave a comment:


  • windracer
    replied
    Confirming it's the API version on the fan controller. My BN-LINK outlets arrived and I added the first one to the IoT VLAN, refreshed the Tuya plugin and bam, local IP address:

    Click image for larger version  Name:	image.png Views:	0 Size:	19.9 KB ID:	1591307

    Version 3.3 of the API for this device:

    Code:
    2023-02-08 16:14:05.6423|TRACE|UDP broadcast received from 192.168.10.125 Type=UDP_NEW Payload={"ip":"192.168.10.125","gwId":"366163407c87ce8ce77d" ,"active":2,"ability":0,"mode":0,"encrypt":true,"productKey" :"key8yarapn88mvn3","version":"3.3"}
    ​
    I'm also seeing the DP_QUERY results in the debug log for it and was able to enable local control.

    Click image for larger version  Name:	image.png Views:	0 Size:	73.6 KB ID:	1591313
    Click image for larger version  Name:	image.png Views:	0 Size:	27.1 KB ID:	1591320

    ​I didn't get the "Local Control" feature added to the device like the instructions mention (edit: I did after I re-created the HS device), but I do see the ping/pongs in the debug log and the device works in HS4, so yeah, local control! Whew, if I had just started with a "supported" device I wouldn't have gone down that VLAN/UDP broadcast rabbit hole.

    Sorry for all the trouble, but glad I could at least be helpful in pointing out the new API revision.

    Leave a comment:


  • windracer
    replied
    Oh, and now that I know that the broadcast stuff appears in the trace log, I moved the controller back to my IoT VLAN and my HS4 Pi can still see the UDP broadcasts on the 192.168.10.0/24 VLAN (via the multi-homed virtual NIC). So hopefully the issue is just the API version. 👍

    Code:
    2023-02-08 14:41:41.1108|TRACE|UDP broadcast received from 192.168.10.124 Type=35 Payload={"ip":"192.168.10.124","gwId":"ebd9fbd0372a93b570reo0","active":2,"ablilty":0,"encrypt":true,"productKey":"fcldsaadc3hzf9ey","version":"3.4","token":true,"wf_cfg":true}

    Leave a comment:


  • windracer
    replied
    Ah, nice! So I wasn't just banging my head against a wall for nothing ... maybe it wasn't the VLAN/broadcast stuff after all! Wow, for a fan controller I'm surprised it's "current" on APIs.

    Here it is: https://www.amazon.com/gp/product/B07Z948VY4

    I ordered some BN-LINK Smart Plugs (recommended by TC1 above) that should be here tonight so I can test with those too.

    Leave a comment:


  • spud
    replied
    It doesn't work because your device uses a new API version 3.4, with some new message types and encryption. The plugin only supports 3.1 and 3.3 versions.

    I will create an internal enhancement request to support 3.4.

    Where did you buy this device? Do you have an amazon link or similar? Thanks

    Leave a comment:


  • windracer
    replied
    Started from scratch ...

    - removed controller from app
    - uninstalled plug-in (cleaned up stuff left behind like Tuya.ini and directory under bin)
    - re-paired controller in app on primary VLAN
    - confirmed I could see the device with DHCP lease from router on primary VLAN (192.168.1.116)
    - confirmed I could control the device from the app
    - re-installed 4.0.39.0 beta of the Tuya plug-in (set trace log level, local discovery timeout, etc.)
    - authorized Tuya account
    - read devices, fan controller appeared, no IP, but in the trace log I can see the broadcasts being received:

    Code:
    2023-02-08 11:50:25.0739|TRACE|UDP broadcast received from 192.168.1.116 Type=35 Payload={"ip":"192.168.1.116","gwId":"eb4c76745014f70a4d1hac","active":2,"ablilty":0,"encrypt":true,"productKey":"fcldsaadc3hzf9ey","version":"3.4","token":true,"wf_cfg":true}
    ​​
    - added the device to HS

    Code:
    2023-02-08 11:50:38.2172|DEBUG|PostBackProc page=manage-devices.html, data=action=import_devices&eb4c76745014f70a4d1hac=on
    2023-02-08 11:50:38.3782|DEBUG|Fan - primary VLAN: Created Root HS Device #583
    2023-02-08 11:50:38.4835|DEBUG|Fan - primary VLAN: Created HS Feature State #584
    2023-02-08 11:50:38.5343|DEBUG|Fan - primary VLAN: Created HS Feature switch #585
    2023-02-08 11:50:38.6170|DEBUG|Fan - primary VLAN: Created HS Feature fan_speed #586
    2023-02-08 11:50:38.7148|DEBUG|Fan - primary VLAN: Created HS Feature light #587
    2023-02-08 11:50:38.7842|DEBUG|Fan - primary VLAN: Created HS Feature fan_beep #588
    ​
    - did another "read" of Tuya devices

    Code:
    2023-02-08 11:52:00.8618|DEBUG|PostBackProc page=manage-devices.html, data=action=read_devices
    2023-02-08 11:52:00.8618|DEBUG|Request:Method: GET, RequestUri: 'https://openapi.tuyaus.com/v1.0/users/az1675869736100mK1AG/devices', Version: 2.0, Content: <null>, Headers:
    {
    <snip>
    }
    2023-02-08 11:52:01.0060|DEBUG|Response:StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.HttpConnection+HttpConnectionResponseContent , Headers:
    {
    Connection: keep-alive
    Date: Wed, 08 Feb 2023 16:52:00 GMT
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Headers:
    Access-Control-Allow-Headers: access_token,Content-Type
    Access-Control-Allow-Methods: POST
    Access-Control-Allow-Methods: OPTIONS
    Access-Control-Allow-Methods: GET
    Access-Control-Allow-Methods: DELETE
    Access-Control-Allow-Methods: PUT
    Access-Control-Allow-Origin: https://iot.tuya.com
    Gateway-Info: highway
    Server: Tuya-Sec
    Strict-Transport-Security: max-age=31536000
    Content-Type: application/json; charset=UTF-8
    Content-Length: 832
    }
    2023-02-08 11:52:01.0060|DEBUG|{"result":[{"active_time":1675873052,"biz_type":18,"category":"fsd","cr eate_time":1675873052,"icon":"smart/icon/ay1512497784834trnvi/15581809942e4c56820f3.jpg","id":"eb4c76745014f70a4d1hac","ip ":"96.59.161.42","lat":"27.8621","local_key":"bdcbb69923befa ea","lon":"-82.8059","model":"QI-FLRC-1","name":"Fan - primary VLAN","online":true,"owner_id":"98312748","product_id":"fcld saadc3hzf9ey","product_name":"Ceiling fan light","status":[{"code":"switch","value":"false"},{"code":"fan_speed","value ":"1"},{"code":"countdown","value":"0"},{"code":"countdown_l eft","value":"0"},{"code":"light","value":"false"},{"code":" fan_beep","value":"false"}],"sub":false,"time_zone":"-05:00","uid":"az1675869736100mK1AG","update_time":1675873103 ,"uuid":"74d51e2358fecb20"}],"success":true,"t":1675875120949,"tid":"e8350c92a7d011edbff c1a964d43bd76"}
    Still no local IP listed.

    Click image for larger version  Name:	image.png Views:	0 Size:	16.1 KB ID:	1591258

    Leave a comment:


  • spud
    replied
    Originally posted by windracer View Post
    Yep. I keep seeing my WAN (external) IP in the Tuya tab of the device.
    The JSON data you see on the Tuya tab is coming from the Tuya cloud. The IP you see there will always be your WAN IP and it's ok.

    To discover the local IP of your devices, the plugin listen on UDP ports 6666 and 6667 at start up or when you click the "Read Tuya Devices" button from the "Manage Devices" page. Every Tuya device is constantly broadcasting some packets on those ports to be able to be discovered.

    To troubleshoot:
    • install the latest beta of the plugin version 4.0.39
    • in this version, from the settings page you can change the timeout used for discovery, set this to something like 30 seconds.
    • install your device in the same LAN as HS4
    • then try to do the discovery again and see if you get the IP address in the "Manage Devices" page.

    If it is still not working please post the logs at Trace level.

    Leave a comment:


  • windracer
    replied
    I do have IGMP/multicast enabled on the Unifi APs as well.

    Good idea on the second device.

    Leave a comment:


  • TC1
    replied
    Originally posted by windracer View Post

    No firewall running on the Hometroller Pi, but everything goes through my Edgerouter which is where the VLANs, port tagging, firewall rules, etc. is all set up. I agree it's probably something with the UDP broadcast packets. Or it's just crappy firmware on this Chinese controller that's reporting that WAN IP instead of it's actual local IP which is mucking up the works, who knows.
    I do know that on my UniFi wireless APs and Ethernet switches I had to enable allow multicast broadcasts before things worked. I would also suggest get another cheap Tuya device we all know works, just to rule out your current device that's giving you problems. My BN-LINK Smart Plugs cost like $8 from Amazon.

    Leave a comment:


  • windracer
    replied
    Originally posted by TC1 View Post
    You connected it to the primary LAN and still didn't see the local IP show in the Tuya Device Management page in the plugin??
    Yep. I keep seeing my WAN (external) IP in the Tuya tab of the device.

    Originally posted by TC1 View Post
    Have you tried putting it back on the primary LAN, deleting the HS4 device, re-reading the Tuya device on the plugin Device management page?
    Yep.

    Originally posted by TC1 View Post
    If you did all that then the only thing I can think of is that there's something blocking the UDP broadcasts that are needed, I'm not a Pi/Linux expert but it seems like there might be a firewall/IPTables issue on your HS4 install?
    No firewall running on the Hometroller Pi, but everything goes through my Edgerouter which is where the VLANs, port tagging, firewall rules, etc. is all set up. I agree it's probably something with the UDP broadcast packets. Or it's just crappy firmware on this Chinese controller that's reporting that WAN IP instead of it's actual local IP which is mucking up the works, who knows.

    I'm going out of town this weekend so won't have more time to tinker until next week. And getting local control working isn't a priority (especially for a ceiling fan and light) but I wanted to see if I could get it working.

    Thanks again for your help.

    Leave a comment:


  • TC1
    replied
    You connected it to the primary LAN and still didn't see the local IP show in the Tuya Device Management page in the plugin??

    Have you tried putting it back on the primary LAN, deleting the HS4 device, re-reading the Tuya device on the plugin Device management page?

    If you did all that then the only thing I can think of is that there's something blocking the UDP broadcasts that are needed, I'm not a Pi/Linux expert but it seems like there might be a firewall/IPTables issue on your HS4 install?

    When I did my initial VLAN IoT experiments in the beginning of this thread I had the benefit of all the HS4-to-device communication going through my firewall, which gave me visibility as to what was being attempted between the two endpoints. Since you're multihoming then the Pi becomes the router, you need to be able to observe the dropped/blocked packets to and from the Tuya device.

    But I digress, if you can't even get it to work on the same primary LAN segment then something is fundamentally wrong. You need to turn off any firewalling/filtering on the Pi if it's active.

    Leave a comment:


  • windracer
    replied
    Yeah, I know multi-homed isn't the best, and I won't go into detail about why I did what I did, but I did try connecting the fan controller to the primary LAN, which should be the subnet as the interface the plug-in is binding too, and I still never saw a local IP address reflected.

    Anyway, yes, I can control the device from Homeseer, and here's the section in the Tuya.ini file:

    Code:
    [TUYA]
    schema=tuyasmart
    accesstoken=<redacted>
    [DEVICES]
    selected=eb92735683fd8f2452sdiq
    [GENERAL]
    poll_interval=1
    log_level=Info
    send_dp_query=True
    log_to_file_enabled=True
    ​
    Appreciate the help.

    Leave a comment:


  • TC1
    replied
    Ok, I think I know what the problem is, I suspect the plugin is binding to the other interface on your multi-homed setup. I'm not a big fan of what you are doing (multi-homing is a security risk and headaches while troubleshooting, this is a prime example) but let's try to figure it out...

    I'm assuming you can control the Tuya physical device from the device controls in HS4, correct?

    If so, in you HS4 install directory \HomeSeer HS4\Config\ there should be a Tuya.ini file with a [DEVICES] section, what are the contents?

    Leave a comment:

Working...
X