mirror of
https://github.com/ZaneThePython/openjibo-haint.git
synced 2026-06-17 11:46:01 +00:00
feat: Initallize
This commit is contained in:
52
__init__.py
Normal file
52
__init__.py
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import asyncio
|
||||||
|
import aiohttp
|
||||||
|
import voluptuous as vol
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
import logging
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
async def async_setup(hass: HomeAssistant, config: dict):
|
||||||
|
"""Set up the Jibo integration."""
|
||||||
|
|
||||||
|
async def handle_say_service(call):
|
||||||
|
message = call.data.get("message")
|
||||||
|
ip = hass.data[DOMAIN]["jibo_ip"]
|
||||||
|
url = f"http://{ip}:8089/tts_speak"
|
||||||
|
payload = {
|
||||||
|
"prompt": message,
|
||||||
|
"locale": "en-us",
|
||||||
|
"voice": "griffin",
|
||||||
|
"duration_stretch": 1,
|
||||||
|
"pitch": 3,
|
||||||
|
"pitchBandwidth": 0.4,
|
||||||
|
"mode": "text",
|
||||||
|
"outputMode": "stream",
|
||||||
|
"timeout": None,
|
||||||
|
"volume": 0,
|
||||||
|
"whisper": "FALSE",
|
||||||
|
"samplerate": 48000,
|
||||||
|
"postfilter": 0.4,
|
||||||
|
"framerate": 240,
|
||||||
|
"unvoicedvoiced": 0.35,
|
||||||
|
"allPass": 0.76,
|
||||||
|
"gvMCEP": 0.9,
|
||||||
|
"cached": "TRUE"
|
||||||
|
}
|
||||||
|
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
try:
|
||||||
|
async with session.post(url, json=payload) as response:
|
||||||
|
if response.status != 200:
|
||||||
|
_LOGGER.error("Failed to speak: %s", await response.text())
|
||||||
|
except aiohttp.ClientError as e:
|
||||||
|
_LOGGER.error("Error communicating with Jibo: %s", e)
|
||||||
|
|
||||||
|
hass.services.async_register(DOMAIN, "say", handle_say_service)
|
||||||
|
return True
|
||||||
|
|
||||||
|
async def async_setup_entry(hass, entry):
|
||||||
|
"""Store IP from config flow."""
|
||||||
|
hass.data[DOMAIN] = {"jibo_ip": entry.data["jibo_ip"]}
|
||||||
|
return True
|
||||||
BIN
brand/icon.png
Normal file
BIN
brand/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
BIN
brand/logo.png
Normal file
BIN
brand/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
17
config_flow.py
Normal file
17
config_flow.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import voluptuous as vol
|
||||||
|
from homeassistant import config_entries
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
class JiboConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
VERSION = 1
|
||||||
|
CONNECTION_CLASS = config_entries.CONN_CLASS_LOCAL_POLL
|
||||||
|
|
||||||
|
async def async_step_user(self, user_input=None):
|
||||||
|
if user_input is not None:
|
||||||
|
return self.async_create_entry(title="Jibo", data=user_input)
|
||||||
|
|
||||||
|
data_schema = vol.Schema({
|
||||||
|
vol.Required("jibo_ip"): str
|
||||||
|
})
|
||||||
|
return self.async_show_form(step_id="user", data_schema=data_schema)
|
||||||
10
manifest.json
Normal file
10
manifest.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"domain": "jibo",
|
||||||
|
"name": "OpenJibo",
|
||||||
|
"version": "0.1.0.a",
|
||||||
|
"documentation": "https://jibohacks.zane.org/homeassistant/int",
|
||||||
|
"requirements": [],
|
||||||
|
"dependencies": [],
|
||||||
|
"codeowners": ["@ZaneThePython"],
|
||||||
|
"config_flow": true
|
||||||
|
}
|
||||||
7
services.yaml
Normal file
7
services.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
say:
|
||||||
|
description: Make Jibo Say Something
|
||||||
|
fields:
|
||||||
|
message:
|
||||||
|
description: Text to speak
|
||||||
|
example: "Hello Home Assistant"
|
||||||
|
required: true
|
||||||
Reference in New Issue
Block a user