leeyuentuen / localtuya

local handling for Tuya devices
GNU General Public License v3.0
72 stars 17 forks source link

It prompts to add entity even if _Is gateway_ is ticked #31

Closed felipecrs closed 1 year ago

felipecrs commented 1 year ago

I think it was not supposed to do that. Was it?

https://user-images.githubusercontent.com/29582865/212754433-2cae7166-3e24-4d1a-ae30-570477a90bf9.mp4

nhailong commented 1 year ago

Having the same issue here

alexualbu commented 1 year ago

@felipecrs , @nhailong which version are you on?

felipecrs commented 1 year ago

v3.6.4

alexualbu commented 1 year ago

The simplest cause for this I can think of is that the device is either not a gateway or it somehow has DPs - the code now assumes that a gateway does not have DPs so if it finds any the "is gateway" checkbox is basically disregarded. You could eliminate this hypothesis by either going to the next step in the flow and seeing if any DPs are available or in the Tuya Cloud console by checking Device Specification

felipecrs commented 1 year ago

Makes sense.

This is the output for my bluetooth & zigbee hub:

{
  "result": {
    "category": "wg2",
    "functions": [
      {
        "code": "switch_alarm_sound",
        "lang_config": {
          "false": "",
          "true": ""
        },
        "name": "Switch alarmsound",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "master_state",
        "lang_config": {
          "alarm": "",
          "normal": ""
        },
        "name": "Master state",
        "type": "Enum",
        "values": "{\"range\":[\"normal\",\"alarm\"]}"
      },
      {
        "code": "factory_reset",
        "lang_config": {
          "false": "",
          "true": ""
        },
        "name": "Factory reset",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "alarm_active",
        "lang_config": {
          "unit": ""
        },
        "name": "Alarm active",
        "type": "String",
        "values": "{\"maxlen\":255}"
      }
    ],
    "status": [
      {
        "code": "switch_alarm_sound",
        "lang_config": {
          "false": "",
          "true": ""
        },
        "name": "Switch alarmsound",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "master_state",
        "lang_config": {
          "alarm": "",
          "normal": ""
        },
        "name": "Master state",
        "type": "Enum",
        "values": "{\"range\":[\"normal\",\"alarm\"]}"
      },
      {
        "code": "factory_reset",
        "lang_config": {
          "false": "",
          "true": ""
        },
        "name": "Factory reset",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "alarm_active",
        "lang_config": {
          "unit": ""
        },
        "name": "Alarm active",
        "type": "String",
        "values": "{\"maxlen\":255}"
      }
    ]
  },
  "success": true,
  "t": 1674572793476,
  "tid": "b07b47329bf811ed858bc232723a3483"
}
alexualbu commented 1 year ago

That's interesting. I assume it makes sense that some gateways would also expose some functions - it seems that this gateway is alarm related. I guess in this case the logic is in order and it should be ok for you to add a entity just to be able to set it up.

felipecrs commented 1 year ago

Hm... that makes sense, but what if I don't want to add any entity? I think it would be helpful to have an option like Do not prompt for adding entities in this case.

alexualbu commented 1 year ago

I believe this is the paradigm for LocalTuya in general - I am not sure you can add a non-gateway device without adding any of its entities. So although I see your point, this approach would also make sense in this case.

alexualbu commented 1 year ago

Hi, @felipecrs ! I added the second gateway I had not used and, concidence, it's the same as yours. So I found an easy way to add an option in the config flow for this. Opened a PR which is referenced above.

alexualbu commented 1 year ago

@felipecrs, can you test the latest release (3.6.6) and confirm it's ok?

felipecrs commented 1 year ago

I tried to add my hub today again but for some reason it's failing with Unknown error. Checking the logs it says it timeouts.

It should be a problem with my hub, so let's close this issue. Thanks a lot!

AlirezaT commented 1 year ago

I have a Bluetooth gateway which is a socket with relay and power measurement. ALUSSO Gateway

that might also fix this conflict.

I've tried to is_gateway: false in configuration.yaml but the BL light becomes unavailable by doing this!

I need to have is_gateway: true & define entities for the Hub at the same time