StyraHem / ShellyForHASS

Shelly smart home platform for Home Assistant
MIT License
620 stars 111 forks source link

[FR] sensor for shelly button 1 #547

Open jpearce73 opened 3 years ago

jpearce73 commented 3 years ago

Is your feature request related to a problem? Please describe.

I'd like the Shelly Button 1 to be a bit easier to use. Currently the only way to use it is with events.

Describe the solution you'd like

I really like the sensor entity created for the Sonoff button by the Sonoff LAN integration. https://github.com/AlexxIT/SonoffLAN

The sensor's state is normally empty or null. And when pressed its state briefly goes to "single", "double", or "hold" and this is a lot more natural for novice users to configure in the Automation GUI.

By contrast, shelly for has creates a binary sensor for the switch, which isn't much use because it loses the kind of click.

Describe alternatives you've considered

Don't remove the events, advanced users might prefer them Allow the sensor to be created on request via the same mechanism all your sensors are added.

Additional context

Here is a screenshot of the sonoff sensor in the history graph. We have instantaneous single, double, and hold states.

2021-04-10 (2)

jpearce73 commented 3 years ago

Related to this but probably a bug - there is a rouge event generated by shellyforhass.click when you do a long press I get two events fired from a long press, the first is type "null", then the propper type "long"

Event 13 fired 12:38 PM:
{
    "event_type": "shellyforhass.click",
    "data": {
        "entity_id": "binary_sensor.shelly_shbtn_2_84cca8ac40b7_switch",
        "click_type": "long"
    },
    "origin": "LOCAL",
    "time_fired": "2021-04-10T11:38:10.140958+00:00",
    "context": {
        "id": "0ec388433176a5384198fa83a9cfe5f1",
        "parent_id": null,
        "user_id": null
    }
}

Event 12 fired 12:38 PM:
{
    "event_type": "shellyforhass.click",
    "data": {
        "entity_id": "binary_sensor.shelly_shbtn_2_84cca8ac40b7_switch",
        "click_type": null
    },
    "origin": "LOCAL",
    "time_fired": "2021-04-10T11:38:09.478862+00:00",
    "context": {
        "id": "b7e1ad30bd78cd1dee7837a6d5f678d4",
        "parent_id": null,
        "user_id": null
    }
}