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

developing branch: switch_curtain_command errors #23

Open
CJDumbleton opened this issue Feb 21, 2023 · 10 comments
Open

developing branch: switch_curtain_command errors #23

CJDumbleton opened this issue Feb 21, 2023 · 10 comments

Comments

@CJDumbleton
Copy link

Re developing branch: I made errors in the switchbot_curtain_command. Do you want me to fix it and do another pull request? It should be as follows:

@service
def switchbot_curtain_command(device=None, command=None, parameter=None):
    """yaml
name: SwitchBot Curtain Command
description: Control Switchbot curtain.
fields:
  device:
    name: Device
    description: the name of the device as in the SwitchBot app
    example: cover.switchbot_remote_bedroom_curtains
    default:
    required: true
    selector:
      entity:
        domain: cover

  command:
    name: Command
    description: the name of the command
    example: turnOff
    default: 
    required: true
    selector:
      select:
        options:
          - turnOn
          - turnOff
          - setPosition
        mode: list

  parameter:
    name: Parameters
    description: the setPosition command requires a position parameter
    example: 
    default: 
    required: false
    selector:
      number:
        min: 0
        max: 100
        step: 1
        mode: box
    """
    deviceId = extract_device_id(device)
    headers_dict = auth(**pyscript.app_config)
    if parameter != None:
      parameter_string = "0,ff," + str(parameter)
      command_execute(headers_dict, deviceId, command, parameter=parameter_string)
    else:
      command_execute(headers_dict, deviceId, command, parameter=parameter)
@SiriosDev
Copy link
Owner

I'm tweaking a few things here and there, (don't mind the icons, the UI and the lack of automatic get status. I'm working on it) could you try the curtain service from the last developing branch?

@SiriosDev
Copy link
Owner

SiriosDev commented Feb 21, 2023

I revolutionized it and would like to know if it works. since I don't have this device.

@CJDumbleton
Copy link
Author

Tested curtain service from latest developing branch:

  • turnOn - success✅
  • turnOff - success✅
  • setPosition:
    • Mode: Default; Position 50% - success✅
    • Mode: Performance; Position 25% - success✅
    • Mode: Silent; Position 75% - success✅

General comments:

  • Some typos in 'name' field: 'Indexs' should be 'Index'. 'Modes' should be 'Mode'.
  • My Curtain makes the same amount of noise using 'Performance' or 'Silent' even when I use the Switchbot official app. So, I can't test the difference between 'Performance' and 'Silent'.
  • I can't get the slider to work in the HA service view. The slider is always fully closed. I can't drag it to a different setting. I have to enter the Position number in the text box.

Home Assistant service settings view

@SiriosDev
Copy link
Owner

I thank you, from haste I put everything in plural now I'll correct 😅, for the modes, I think that having started the command they work, for the slider I opened an issue on the pyscript repo because apparently, it is a "their problem".

I'm not closing the issue because if I need any test I'll write it here.

Ah about that, do you know what the index should indicate? by default, I put 0 but I'm trying to figure out by asking here (still unanswered)

@CJDumbleton
Copy link
Author

I don't know what index refers to. I tried setting the index to 0, 1, 10 and 100. The setPosition command worked correctly every time with no difference.

@SiriosDev
Copy link
Owner

a true mystery

@SiriosDev
Copy link
Owner

SiriosDev commented Feb 21, 2023

I made more progress on the services and tweaked some descriptions, as soon as you can you could test all the services you can (excluding the curtain that was not changed) and if I wrote something wrong in the descriptions since I am Italian maybe I wrote something wrong

@CJDumbleton
Copy link
Author

Tested the following services from the latest developing branch (spoiler - all tests were successful!):

  • switchbot_refresh_devices - successfully refreshed Bot, Contact Sensor, Meter and Curtains ✅

    • Two changes to description in italics: This service lists registered devices in the "Switchbot Hub".
  • switchbot_bot

    • turnOn - Bot activated ✅
    • turnOff - Bot activated ✅
    • press - 1 repetition - Bot activated ✅
    • press - 2 repetitions - Bot activated 2 times ✅
    • One change to description in italics: Number of repetitions (required for "press" command) ("1" by Default)
    • My tests didn't always work the first time I called the service. I think that's due to the distance of my bot from the hub. Sometimes I had to try three times.
    • I have my bot set up in 'press' mode. So, I can't test turnOn and turnOff in the way they're supposed to be used in 'switch' mode. See screenshot from bot user manual for your information. However, turnOn and turnOff still both successfully activate the bot for me.

Screenshot 2023-02-22 at 16 25 35

  • switchbot_turn_on

    • Bot - Bot activated ✅
  • switchbot_turn_off

    • Bot - Bot activated ✅
  • switchbot_generic_command

    • Bot - turnOn - Bot activated ✅
    • One change to description in italics: For customized buttons, this needs to be set to customize

Checked the descriptions for the following services which I am unable to test:

  • switchbot_ir_hvac - no changes to description
  • switchbot_ir_light - no changes to description

@SiriosDev
Copy link
Owner

thank you very much, so the bots don't work with all three basic commands are two separate modes, I will write it in some description.

@SiriosDev
Copy link
Owner

now it remains to reintegrate the auto-get status, and the corrections you provided, if no new pr comes, I think, I will merge on the main (and as a result the new version) around Friday/Saturday

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