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

Added ZHA Yphix/Namron 2 Channel Switch #123

Merged
merged 9 commits into from
May 14, 2023

Conversation

pieterdevriesch
Copy link
Contributor

@pieterdevriesch pieterdevriesch commented May 7, 2023

Blueprint Checklist

  • You viewed the README and conformed to the naming conventions
  • You ordered the actions as stated in the README action order
  • All filenames are lowercase and uses '-' for spaces and not '_' while using {service-name}-{switch-name-or-type}.yaml format
  • Images are png
  • Image backgrounds are transparent and is cropped to the device boundries
  • Images has a maximum width of 800px and maximum height of 500px
  • There are no missing buttons or actions
  • Your integration/service is running on the latest version
  • You have tested your blueprints and made sure each button and action works

Just managed to fix my blueprint after discovering that @bendikrb was working on a switch from a different brand that's clearly the exact same one as mine. I put the brand name of mine on it but maybe it could be changed to both (although there might be more rebranded versions).

Blueprint for zigbee 2 channel switch sold under names of Yphix and Namron, probably more.
Added transparancy
@Sian-Lee-SA
Copy link
Owner

Seems the PR from bendikrb was never committed so isn't apart of this repo (think was due to lack of updating the PR to conform with the guidelines). With that said, Feel free to name the devices to the core vendor or whatever would be easily distinguishable for other users.

Also for better readability and logic, you will want to put the endpoint conditions as a button condition and not on each action. I would also advise to use key value pairs for condition checks instead of Jinja templated conditions.

@pieterdevriesch
Copy link
Contributor Author

Seems the PR from bendikrb was never committed so isn't apart of this repo (think was due to lack of updating the PR to conform with the guidelines). With that said, Feel free to name the devices to the core vendor or whatever would be easily distinguishable for other users.

I only have this one switch so I have no idea who is the core vendor. Until I found bendikrb's PR I didn't even know it was available under different brands. Anyway I'll see if I can find out something.

Also for better readability and logic, you will want to put the endpoint conditions as a button condition and not on each action. I would also advise to use key value pairs for condition checks instead of Jinja templated conditions.

The endpoint should be ok but when I tried it as key value pairs it didnt work properly (it would not differentiate between the different buttons for hold state, the only difference between them is in the params section and it would not work.) That's the thing I learned from bendikrb's version, because this way it actually works.

@Sian-Lee-SA
Copy link
Owner

I assume this following should work

  - x: 86
    y: 86
    width: 127
    height: 214
    conditions:
        - key: endpoint_id
          value: 1     
    actions:
      - title: press
        conditions:
          - key: cluster_id
            value: 6
          - key: command
            value: 'on'
      - title: hold
        conditions:
          - key: cluster_id
            value: 8
          - key: command
            value: 'move_with_on_off'
          - key: params.move_mode
            value: 0
      - title: hold (released)
        conditions:
          - key: cluster_id
            value: 8
          - key: command
            value: stop_with_on_off
          - key: button_last_state.0.title
            value: hold

Renamed blueprint to namron; On the Blakadder database there are numerous namron devices including this exact one, while yphix only shows 2 entries. Using the namron name will make it more likely to be found by people who use it.

Made the organisational changes requested by sian-lee-sa in the pull request.
Renamed blueprint to other brand
Renamed blueprint to other brand
@pieterdevriesch
Copy link
Contributor Author

I assume this following should work

That's what I tried originally but maybe I made a mistake. I didn't have the repository forked yet at that point so I can't really look back.
I've made the modifications but I will test it first, this evening when I'm home.

@pieterdevriesch
Copy link
Contributor Author

Finally had time to test.
I did not make a mistake before. It only recognises the hold action when using the templated conditions, not as key/value pairs.

      - title: hold
        conditions:
          - key: cluster_id
            value: 8
          - key: command
            value: 'move_with_on_off'
          - key: params.move_mode
            value: 0

Does not work, while:

      - title: hold
        conditions: >
          {{ data.cluster_id == 8
          and data.command == 'move_with_on_off'
          and data.params.move_mode == 0 }}

does. I also don't understand why since both methods say the exact same thing.

Just let me know if you want to troubleshoot this some more or just accept the templated version?

@Sian-Lee-SA
Copy link
Owner

Sian-Lee-SA commented May 13, 2023

So it's just the hold action that's having the issue? If so, I think the params.move_mode being zero is defaulting to False as 0 is false. If that's the case, could you just change that one to the working version and I will merge then debug and change if necessary on my end.

Also could you post an example payload for that action so I have data to work with instead of writing it out from scratch.

@pieterdevriesch
Copy link
Contributor Author

Done.

Here's the hold payload:

event_type: zha_event
data:
  device_ieee: cc:cc:cc:ff:fe:64:43:c6
  unique_id: cc:cc:cc:ff:fe:64:43:c6:1:0x0008
  device_id: 5d12e7476d2e470b33b7bb2bf8d6407b
  endpoint_id: 1
  cluster_id: 8
  command: move_with_on_off
  args:
    - 0
    - 50
  params:
    move_mode: 0
    rate: 50
origin: LOCAL
time_fired: "2023-05-13T21:51:33.950870+00:00"
context:
  id: 01H0BHHZHYQX5YE0EN9B553GD2
  parent_id: null
  user_id: null

and the hold(release):

event_type: zha_event
data:
  device_ieee: cc:cc:cc:ff:fe:64:43:c6
  unique_id: cc:cc:cc:ff:fe:64:43:c6:1:0x0008
  device_id: 5d12e7476d2e470b33b7bb2bf8d6407b
  endpoint_id: 1
  cluster_id: 8
  command: stop_with_on_off
  args: []
  params: {}
origin: LOCAL
time_fired: "2023-05-13T21:51:35.095622+00:00"
context:
  id: 01H0BHJ0NQBYFRXQGCC1RYXZFK
  parent_id: null
  user_id: null

That was the top left (I) button. Top right (O) is with args 1:

event_type: zha_event
data:
  device_ieee: cc:cc:cc:ff:fe:64:43:c6
  unique_id: cc:cc:cc:ff:fe:64:43:c6:1:0x0008
  device_id: 5d12e7476d2e470b33b7bb2bf8d6407b
  endpoint_id: 1
  cluster_id: 8
  command: move_with_on_off
  args:
    - 1
    - 50
  params:
    move_mode: 1
    rate: 50
origin: LOCAL
time_fired: "2023-05-13T21:58:16.455350+00:00"
context:
  id: 01H0BHY8M7Q256DCKG7KA85WWB
  parent_id: null
  user_id: null
event_type: zha_event
data:
  device_ieee: cc:cc:cc:ff:fe:64:43:c6
  unique_id: cc:cc:cc:ff:fe:64:43:c6:1:0x0008
  device_id: 5d12e7476d2e470b33b7bb2bf8d6407b
  endpoint_id: 1
  cluster_id: 8
  command: stop_with_on_off
  args: []
  params: {}
origin: LOCAL
time_fired: "2023-05-13T21:58:17.935386+00:00"
context:
  id: 01H0BHYA2F0J6973A9KMNCXDE0
  parent_id: null
  user_id: null

@Sian-Lee-SA
Copy link
Owner

Thanks, I'll have a look into it

@Sian-Lee-SA Sian-Lee-SA merged commit c2738e7 into Sian-Lee-SA:master May 14, 2023
@Sian-Lee-SA Sian-Lee-SA changed the title Yphix/Namron 2 Channel Switch Blueprint Added ZHA Yphix/Namron 2 Channel Switch May 14, 2023
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

Successfully merging this pull request may close these issues.

2 participants