Hej
jest gdzieś opisane tworzenie integracji dla opornych ? ;D
Próbuję coś zdziałać z integracją it4wifi na podstawie integracji dla OH
import logging
import requests
from homeassistant.components.switch import SwitchEntity
from homeassistant.const import CONF_NAME
_LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the IT4Wifi switch platform."""
name = config.get(CONF_NAME)
add_entities([It4WifiSwitch(name)])
class It4WifiSwitch(SwitchEntity):
"""Representation of an IT4Wifi switch."""
def __init__(self, name):
"""Initialize the IT4Wifi switch."""
self._name = name
self._state = False
@property
def name(self):
"""Return the name of the switch."""
return self._name
@property
def is_on(self):
"""Return true if the switch is on."""
return self._state
def turn_on(self, **kwargs):
"""Turn the switch on."""
self._state = True
self._send_command('open')
def turn_off(self, **kwargs):
"""Turn the switch off."""
self._state = False
self._send_command('close')
def _send_command(self, command):
"""Send a command to the IT4Wifi module."""
url = f"http://<IP_ADDRESS>/send_command?cmd={command}"
response = requests.get(url)
if response.status_code == 200:
_LOGGER.info(f"Successfully sent command: {command}")
else:
_LOGGER.error(f"Failed to send command: {command}")
import logging
from homeassistant.helpers import discovery
_LOGGER = logging.getLogger(__name__)
DOMAIN = 'it4wifi'
def setup(hass, config):
"""Set up the IT4Wifi component."""
_LOGGER.info("Starting setup for IT4Wifi component")
hass.states.set(f"{DOMAIN}.setup", "Starting")
# Discover and load platforms
for component in ['switch']:
_LOGGER.info(f"Attempting to load platform: {component}")
discovery.load_platform(hass, component, DOMAIN, {}, config)
hass.states.set(f"{DOMAIN}.setup", "Completed")
_LOGGER.info("Completed setup for IT4Wifi component")
return True
{
"domain": "it4wifi",
"name": "IT4Wifi",
"documentation": "https://example.com",
"dependencies": [],
"codeowners": ["@your_github_username"],
"requirements": ["requests"]
}
OK po wielu próbach napisania skryptu stanowiącego sam most i licznych próbach autoryzacji przez przypadek znalazłem tą integrację
https://github.com/PatrikTrestik/homeassistant_nicegate
Wrzucam w HA podaje dane, przechodzę dalej podaje kod z naklejki (setup code) i mam ciągle błąd "Unknown error occurred"
Ma możliwość ktoś sprawdzić?
Na Twoim miejscu sprawdziłbym logi. Wtedy można myśleć co nie działa.
Problem z uwierzytelnianiem próbowałem zmienić na nowsze ale się zapetlilem i nie mogę tego przeskoczyć

