Git Product home page Git Product logo

home-assistant-powershell-module's Introduction

Home-Assistant PowerShell Module

A PowerShell Module to Control the Home-Assistant home automation software

Description
This is a project I started with in late 2018 and it hasn't been developed since. But I will publish it anyway and hopefully implement more features in the future

Instructions

Load module to import all functions:

Import-Module .\Home-Assistant

New-HomeAssistantSession neds to be used before any other function will work.

Functions

  Get-HomeAssistantConfig
  Get-HomeAssistantEntity
  Get-HomeAssistantEntity -entity_id <entity_id>
  Get-HomeAssistantServices
  Invoke-HomeAssistantService -service <service> -entity_id <entity_id>
  Invoke-HomeAssistantService -service <service> -json '<json>'
  New-HomeAssistantSession -ip <Home-Assistant IP> -port <Home-Assistant port> -token <access token>

Examples

  
New-HomeAssistantSession -ip 10.0.24.4 -port 8123 -token eyYfo49g036gdKg5LSki4w04tkifulaglgkMn3idnf2w57x5eyfog036gdKg5LSkgw04tkifulaglgkMidnf2w57axyYfo49g036gdKLSkgi4w04tkifaglgkMn3idnf2w57axyYfo49g036gdKg5LSkgi4w04tkifulaglgkMn3idnf2w57ax5
Get-HomeAssistantEntity -entity_id light.limitlessled_g1
Invoke-HomeAssistantService -service light.turn_on -entity_id light.limitlessled_g1
Invoke-HomeAssistantService -service light.turn_on -json '{"entity_id":"light.limitlessled_g1","color_name":"blue"}'

Examples - Advanced/Script/JSON

Use with custom component "hass-variables" https://github.com/rogro82/hass-variables

$cpu_usage_pct = "25"
$json_to_send = '{"variable":"computer_cpu_usage","value":' + '"' +  "$cpu_usage_pct" + '"' + '}'
Invoke-HomeAssistantService -service variable.set_variable -json $json_to_send

Use with custom component "home-assistant-variables" https://github.com/snarky-snark/home-assistant-variables

$cpu_usage_pct = "25"
$json_to_send = '{"entity_id":"var.computer_cpu_usage","value":' + '"' +  "$cpu_usage_pct" + '"' + '}'
Invoke-HomeAssistantService -service var.set -json $json_to_send

Changelog

  • 17.03.2019
    • Release
  • 11.06.2019
    • Updated to better follow PowerShell's best practice for modules. Created folder /Home-Assistant/ and Merged all .ps1 functions to one module file "Home-Assistant.psm1" and Added Module Manifest file "Home-Assistant.psd1"
  • 05.11.2019
    • Added ModuleVersion to module manifest because it is required

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.