Skip to content

Create binary_sensor.xiaomi_gw.markdown #3029

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

Merged
merged 11 commits into from
Jul 23, 2017
Merged

Create binary_sensor.xiaomi_gw.markdown #3029

merged 11 commits into from
Jul 23, 2017

Conversation

jcastro
Copy link
Contributor

@jcastro jcastro commented Jul 20, 2017

Initial commit for binary_sensors sub-component of xiaomi_gw

Description:

Pull request in home-assistant (if applicable): home-assistant/home-assistant#

message: Fire/Smoke detected!
- service: xiaomi.play_ringtone
data:
gw_sid: xxxxxxxxxxxx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should now be gw_mac

action:
service: xiaomi.play_ringtone
data:
gw_sid: xxxxxxxxxxxx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should now be gw_mac

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! fixed 👍

@syssi
Copy link
Member

syssi commented Jul 21, 2017

Do you like to add the following example automation for the cube?

  • Cube
    # Trigger for a few cube events

    - alias: Cube event flip90
      trigger:
        platform: event
        event_type: cube_action
        event_data:
          entity_id: binary_sensor.cube_15xxxxxxxxxxxx
          action_type: flip90
      action:
        - service: light.turn_on
          entity_id: light.gateway_light_28xxxxxxxxxx
          data:
            color_name: "springgreen"
                                                                                                                                                                                                       
    - alias: Cube event flip180                                                                                                                                                                              
      trigger:                                                                                                                                                                                         
        platform: event                                                                                                                                                                                
        event_type: cube_action                                                                                                                                                                        
        event_data:                                                                                                                                                                                    
          entity_id: binary_sensor.cube_15xxxxxxxxxxxx                                                                                                                                                 
          action_type: flip180                                                                                                                                                                         
      action:                                                                                                                                                                                          
        - service: light.turn_on
          entity_id: light.gateway_light_28xxxxxxxxxx
          data:
            color_name: "darkviolet"
                                                                                                                                                                                                       
    - alias: Cube event move                                                                                                                                                                                 
      trigger:                                                                                                                                                                                         
        platform: event                                                                                                                                                                                
        event_type: cube_action                                                                                                                                                                        
        event_data:                                                                                                                                                                                    
          entity_id: binary_sensor.cube_15xxxxxxxxxxxx                                                                                                                                                 
          action_type: move                                                                                                                                                                            
      action:                                                                                                                                                                                          
        - service: light.turn_on
          entity_id: light.gateway_light_28xxxxxxxxxx
          data:
            color_name: "gold"
                                                                                                                                                                                                       
    - alias: Cube event tap_twice                                                                                                                                                                            
      trigger:                                                                                                                                                                                         
        platform: event                                                                                                                                                                                
        event_type: cube_action                                                                                                                                                                        
        event_data:
          entity_id: binary_sensor.cube_15xxxxxxxxxxxx
          action_type: tap_twice
      action:
        - service: light.turn_on
          entity_id: light.gateway_light_28xxxxxxxxxx
          data:
            color_name: "deepskyblue"
    
    - alias: Cube event shake_air
      trigger:
        platform: event
        event_type: cube_action
        event_data:
          entity_id: binary_sensor.cube_15xxxxxxxxxxxx
          action_type: shake_air
      action:
        - service: light.turn_on
          entity_id: light.gateway_light_28xxxxxxxxxx
          data:
            color_name: "blue"

ringtone_id: 2
ringtone_vol: 100
```
- Smoke
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the headline "Smoke" above the "Send notification on fire alarm" automation. :-)

ringtone_vol: 100
```
- Smoke
- Gas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Gas
    # Trigger for natgas detected

    - alias: Send notification on gas alarm
      trigger:
        platform: state
        entity_id: binary_sensor.natgas_sensor_158dxxxxxxxxxx
        from: 'off'
        to: 'on'
      action:
        - service: notify.html5
          data_template:
            title: Gas alarm!
            message: 'Gas with a density of {{ states.binary_sensor.natgas_sensor_158dxxxxxxxxxx.attributes.density }} detected.'

- Smoke
- Gas
- Xiaomi Wireless Button (available events are `single`, `double`, `hold`, `long_click_press` and `long_click_release`).
```yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new/square version of the Xiaomi Wireless Button just supports single and double click. Furthermore the space between two clicks to generate a double click must be quite large now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! everything fixed!

@syssi
Copy link
Member

syssi commented Jul 21, 2017

The wireless wall switch (86sw1, 86sw2) is the last missing binary_sensor. I will provide a few lines tomorrow.

@syssi
Copy link
Member

syssi commented Jul 23, 2017

  • Aqara Wireless Switch

The Aqara Wireless Switch is available as single-key and double-key version. Each key behaves like the Wireless Button limited to the click event single. The double key version adds a third device called binary_sensor.wall_switch_both_158xxxxxxxxx12 which reports a click event called both if both keys are pressed.

    - alias: Decrease brightness of the gateway light                                                                                                                                                                                                                              
      trigger:                                                                                                                                                                                                                                                                 
        platform: event                                                                                                                                                                                                                                                        
        event_type: click                                                                                                                                                                                                                                                      
        event_data:                                                                                                                                                                                                                                                            
          entity_id: binary_sensor.wall_switch_left_158xxxxxxxxx12                                                                                                                                                                                                             
          click_type: single                                                                                                                                                                                                                                                   
      action:                                                                                                                                                                                                                                                                  
        service: light.turn_on                                                                                                                                                                                                                                                 
        entity_id: light.gateway_light_34xxxxxxxx13                                                                                                                                                                                                                            
        data_template:                                                                                                                                                                                                                                                         
          brightness: >-
            {% if states.light.gateway_light_34xxxxxxxx13.attributes.brightness %}
              {% if states.light.gateway_light_34xxxxxxxx13.attributes.brightness - 60 >= 10 %}
                {{states.light.gateway_light_34xxxxxxxx13.attributes.brightness - 60}}
              {% else %}
                {{states.light.gateway_light_34xxxxxxxx13.attributes.brightness}}
              {% endif %}
            {% else %}
              10
            {% endif %}
    
    - alias: Increase brightness of the gateway light
      trigger:
        platform: event
        event_type: click
        event_data:
          entity_id: binary_sensor.wall_switch_right_158xxxxxxxxx12                                                                                                                                                                                                             
          click_type: single
      action:
        service: light.turn_on
        entity_id: light.gateway_light_34xxxxxxxx13
        data_template:
          brightness: >-
            {% if states.light.gateway_light_34xxxxxxxx13.attributes.brightness %}
              {% if states.light.gateway_light_34xxxxxxxx13.attributes.brightness + 60 <= 255 %}
                {{states.light.gateway_light_34xxxxxxxx13.attributes.brightness + 60}}
              {% else %}
                {{states.light.gateway_light_34xxxxxxxx13.attributes.brightness}}
              {% endif %}
            {% else %}
              10
            {% endif %}
    
    - alias: Turn off the gateway light
      trigger:
        platform: event
        event_type: click
        event_data:
          entity_id: binary_sensor.wall_switch_both_158xxxxxxxxx12                                                                                                                                                                                                             
          click_type: both
      action:
        service: light.turn_off
        entity_id: light.gateway_light_34xxxxxxxx13

@jcastro
Copy link
Contributor Author

jcastro commented Jul 23, 2017

Oh nice, do you think it will be possible to also support the award wall switch with its buttons set to wireless mode? (as if shows on the Mi home app preferences for the switch)

@syssi
Copy link
Member

syssi commented Jul 23, 2017

@jcastro Unfortunately, no. The device doesn't fire events in decoupled mode at the moment. I will implement the feature as soon a new gateway firmware introduces a new behaviour.

Copy link
Member

@fabaff fabaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will merge it and address the issues with #3045.

@fabaff fabaff added the new-integration This PR adds documentation for a new Home Assistant integration label Jul 23, 2017
@fabaff fabaff merged commit c753de1 into home-assistant:next Jul 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-integration This PR adds documentation for a new Home Assistant integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants