Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command Syntax for friendly topics #73

Closed
GeraldST opened this issue May 29, 2021 · 3 comments
Closed

Command Syntax for friendly topics #73

GeraldST opened this issue May 29, 2021 · 3 comments

Comments

@GeraldST
Copy link

GeraldST commented May 29, 2021

I cannot figure out how to send commands to friendly topics that I have defined with a Generic Device Template. There is no clue in the documentation either.

First of all, I have set up a Fairland Inverter Heat Pump (for my pool) and this is my devices.conf file:

[
  {
    name: 'Waermepumpe',
    id: 'xxxxx',
    key: 'xxxxx',
    template: {
      state: {
        key: 1,
        type: 'bool'
      },
      mode: {
        key: 2,
        type: 'str'
      },
      WInTemp: {
        key: 102,
        type: 'int'
      },
      change_tem: {
        key: 103,
        type: 'bool'
      },
      SpeedPercentage: {
        key: 104,
        type: 'int'
      },
      SetMode: {
        key: 105,
        type: 'str'
      },
      SetTemp: {
        key: 106,
        type: 'int',
        topicMin: 18,
        topicMax: 40
      },
      SetDnLimit: {
        key: 107,
        type: 'int'
      },
      SetUpLimit: {
        key: 108,
        type: 'int'
      },
      fault1: {
        key: 115,
        type: 'str'
      },
      fault2: {
        key: 116,
        type: 'str'
      }
    }
  }
]

What is working:

  • I get all the DPS-readings of the device
  • Sending message "On" or "Off" to topic tuya/waermepumpe/command (gets translated to {"dps":1,"set":false})
  • Sending message {"dps":106,"set":25} to topic tuya/waermepumpe/dps/command
  • Reading topic tuya/waermepumpe/SetTemp

What is not working:

  • Sending a command to topic tuya/waermepumpe/SetTemp
  • I tried e.g. tuya/waermepumpe/SetTemp/command with message "25", which simply does nothing.

So is this a bug? I had a look into the code and the function processDeviceCommand is only called when topicLength is 3 AND there is the word "command" in the command topic. I cannot figure out how to do this with topicLength 3. "tuya/waermepumpe/SetTemp/command" has a length of 4 ...

Btw. sorry to hear that this project is in maintenance mode. I am quite new to Tuya devices and I really appreciate this for communicating to my heat pump and integrating into FHEM - it already works quite well! I am aware that this project depends on tuyapi - but as long as it is working I will stick to it (I tried cloud API, but my device does not support all functions yet) and appreciate all the work done! Thank's a a lot!

@tsightler
Copy link
Collaborator

I don't think it's a bug, probably just poor documentation that could probably be more clear. The documentation does hint at the right thing to do in the example:

The template above defines two topics "state" and "brightness_state", and the template engine automatically creates the corresponding command topics, in this case specifically "command" and "brightness_command".

Basically, the expectation is the the template defines topics with the suffix of _state, and the engine automatically creates corresponding _command topics, so in your example it should be (just did one for and example):

SetTemp_state: {
        key: 106,
        type: 'int',
        topicMin: 18,
        topicMax: 40
      }

And then you can get state at tuya/waermepumpe/SetTemp_state and send commands to tuya/waermepumpe/SetTemp_command.

@GeraldST
Copy link
Author

Thank you, that's it! So I just added _state to all of my topics and it works now "as expected" ;-)

I read the example several times and misunderstood the description. On the other hand now that you explained it in other words the documentation seems quite clear.

Thank you for your unbelievable fast support!

@tsightler
Copy link
Collaborator

Glad you got it working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants