Asystent AI
Pierwsza własna int...
 
Powiadomienia
Wyczyść wszystko

Home Assistant Pierwsza własna integracja

4 Wpisów
2 Użytkownicy
0 Reactions
1,224 Wyświetleń
(@szpila86)
Wpisów: 367
Weteran Patron Strony Donator 2K22, Donator 2K23, Donator 2K24
Autor tematu
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 
[#5884]

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"]
}

 
Dodane : 02/06/2024 5:59 pm
(@szpila86)
Wpisów: 367
Weteran Patron Strony Donator 2K22, Donator 2K23, Donator 2K24
Autor tematu
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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ć?


 
Dodane : 11/06/2024 12:44 pm
(@konrad1)
Wpisów: 1
Świeżak
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

Na Twoim miejscu sprawdziłbym logi. Wtedy można myśleć co nie działa.


 
Dodane : 25/06/2024 1:36 pm
(@szpila86)
Wpisów: 367
Weteran Patron Strony Donator 2K22, Donator 2K23, Donator 2K24
Autor tematu
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

Problem z uwierzytelnianiem próbowałem zmienić na nowsze ale się zapetlilem i nie mogę tego przeskoczyć 


 
Dodane : 25/06/2024 1:44 pm
Udostępnij: