Skip to main content

This is a plugin that manages the interactions with Homeassistant.

Project description

from jarvisHAplugin.main import HomeAssistantClient

JARVIS-HA-PLUGIN


Python Status Status License

A plugin for The J.A.R.V.I.S. Project that manages and handles all the hand-offs and communications between J.A.R.V.I.S. and a HomeAssistant instance.

Installation


 pip install jarvis-ha-plugin

Documentation


Initializing with the Home Assistant Client

import jarvisHAplugin

ha = jarvisHAplugin.HomeAssistantClient(base_url="http://localhost:8123", token="YOUR HOME ASSISTANT TOKEN HERE")

When you run the program written above, this will initialize a connection between The J.A.R.V.I.S. Project and Home Assistant. These two values are latter used in the other functions since they are part of the core api's function, and they are required to have to make this plugin run properly. Since that is the case with this plugin, the user can have it setup in a way in which the user can set the base_url and the token in a .json file or a .env file and have The J.A.R.V.I.S. Project call out that file to get that information to initialize with the Home Assistant Client. These features later down the line are going to be more streamlined and more user-friendly in terms of not needing to know how to program to get this part of The J.A.R.V.I.S. Project setup and in operating conditions. This is the main part of this plugin that will practically never change when the rest of the plugin is being updated, at any given point if this is changed or modified The J.A.R.V.I.S. Project will alert the user to the change and how to go about correcting it or doing it himself. This initializing command also sets up the base Header set that is needed when The J.A.R.V.I.S. Project is calling out the HomeAssistant API to gather/change variables and various information that is sanctioned between the handoffs between The J.A.R.V.I.S. Project and the HomeAssistantClient.


Turn On a Light

import jarvisHAplugin

ha = jarvisHAplugin.HomeAssistantClient(base_url="http://localhost:8123", token="YOUR HOME ASSISTANT TOKEN HERE")

LIGHT_ENTITY = "light.light_1"

ha.turn_on_light(LIGHT_ENTITY) #Simply Turns on Light (NO OUTPUT)

print(ha.turn_on_light(LIGHT_ENTITY)) #Turns on Light (WITH OUTPUT)

When you run the program written above, this will initialize a connection between The J.A.R.V.I.S. Project and Home Assistant, Which is also referenced in the above portion of the documentation referring to this topic. When you are looking to activate/turn on any given light, you must first get the ID of that specific light entity, this can be found in the settings portion of the light found inside Home Assistant. Once you have gotten the Light's Entity ID, you put it in its respective spot in the program, and the program will call out to the HomeAssistant API endpoint "/api/services/light/turn_on", and proceed with using the given data to activate/turn on the specified light. To turn on/activate multiple lights at a time, you must run the commands separately, and have them run one light at a time, due to the fact that the HomeAssistant API does not accept multiple light entities at once. The J.A.R.V.I.S. Project will handle all the communication, and he will also spit out the output text if that is what he asked to do, or he can just keep a log of it and say the light was changed or turned on successfully.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jarvis_ha_plugin-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file jarvis_ha_plugin-0.1.0.tar.gz.

File metadata

  • Download URL: jarvis_ha_plugin-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for jarvis_ha_plugin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1f39b078023b662aa0172af701365c835dd7960a75697bd94216554b25af5123
MD5 102c266439fe78884e5eab5abf03dba9
BLAKE2b-256 a13d00a2955e166d7ef44e9c165cf7a3f2850cba0f491a3cbd320a9be51bb537

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page