Skip to content
    Back to all Bounties

    Earn 9,000 ($90.00)

    Time Remainingdue 1 year ago
    Completed

    Build two services in Home Assistant

    TaylorSandusky
    TaylorSandusky
    Posted 1 year ago
    This Bounty has been completed!
    @TaylorSandusky's review of @Himanshukuma178
    5.0
    Average Rating
    Communication 5/5, Quality 5/5, Timeliness 5/5

    Bounty Description

    Problem Description

    Home Assistant has an existing user login system. This system has a status for each user of "active" or "inactive". I need the ability to systematically activate/deactivate users. Currently, this can only be done via the UI with clicks.

    Home Assistant has a concept of "services" that can be called in multiple ways. If I could have a service that I can call to activate/deactivate a user, then I can build automations to do this on a schedule, or I can build a UI to make it easy for a user to toggle on/off users in their main dashboard.

    I found this post. https://github.com/permissionBRICK/home-assistant-block-user-switch/blob/main/lockuser/switch.py where someone was able to achieve a similar functionality by building 'switch entities'. However, I would prefer to build the 'services' described above.

    Acceptance Criteria

    A. Two new Home Assistant services:

    1. 'user_access_control.activate_user' - takes a 'username' as an input and then activates that user.
    2. 'user_access_control.deactivate_user' - takes a 'username' as an input and then deactivates that user.
      It might be that Home Assistant requires a 'user_id' and not a 'username'. If this is the case, it would be great if you could build a template that shows 'user_id' and 'username' next to each other so it's easier for me to find 'user_id'. I could display the template in the UI somewhere.

    B. These services need to show up in the 'Developer Tools>Services' UI and the Automation Builder UI. I think the services have to register or be loaded correctly. I got this to work, but struggled to get the code correct.

    C. When the user is activated/deactivated using these services, the correct state needs to show in the standard 'Users' UI. I imagine this will happen automatically, but want to add this to be sure.

    D. Decent logging so that I can troubleshoot if this ever doesn't work.

    The deliverable can essentially be the folders and files that I need to add to the 'custom_components' directory.

    Technical Details

    Mostly Python. Developer docs for building a service (a type of "custom component") in Home Assistant - https://developers.home-assistant.io/docs/creating_component_index

    Link to Project

    Copyright © 2024 Replit, Inc. All rights reserved.
    • twitter
    • tiktok
    • instagram
    • facebook

    Replit

    Programming languages

    • Python
    • JavaScript
    • TypeScript
    • Node.js
    • Nix
    • HTML, CSS, JS
    • C++
    • Golang