Exemplo n.º 1
0
    def _check_host(self, host, username, password) -> bool:
        """Check if we can connect to the kostal inverter."""
        piko = Piko(host, username, password)
        try:
            response = piko._get_info()
        except (ConnectTimeout, HTTPError):
            self._errors[CONF_HOST] = "could_not_connect"
            return False

        return True
async def async_setup_entry(hass, entry, async_add_entities):
    """Add an Kostal piko entry."""
    # Add the needed sensors to hass
    piko = Piko(entry.data[CONF_HOST], entry.data[CONF_USERNAME],
                entry.data[CONF_PASSWORD])
    data = PikoData(piko, hass)

    entities = []

    for sensor in entry.data[CONF_MONITORED_CONDITIONS]:
        entities.append(PikoInverter(data, sensor, entry.title))
    async_add_entities(entities)
Exemplo n.º 3
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up Piko inverter."""
    from kostalpyko.kostalpyko import Piko

    piko = Piko(config[CONF_HOST], config[CONF_USERNAME],
                config[CONF_PASSWORD])

    dev = []
    for sensor in config[CONF_MONITORED_CONDITIONS]:
        dev.append(PikoInverter(piko, sensor))

    add_entities(dev)
Exemplo n.º 4
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up Piko inverter."""
    piko = Piko(config[CONF_HOST],
                config[CONF_USERNAME],
                config[CONF_PASSWORD])

    dev = []
    data = PikoData(piko)
    for sensor in config[CONF_MONITORED_CONDITIONS]:
        dev.append(PikoInverter(data, sensor, config[CONF_NAME]))

    add_entities(dev)
Exemplo n.º 5
0
 def test_get_l3_power(self):
     p = Piko(host='http://example.com')
     self.assertEqual(p.get_l3_power(), 0)
Exemplo n.º 6
0
 def test_get_string3_current(self):
     p = Piko(host='http://example.com')
     self.assertEqual(p.get_string3_current(), 0.0)
Exemplo n.º 7
0
 def test_get_l3_voltage(self):
     p = Piko(host='http://example.com')
     self.assertEqual(p.get_l3_voltage(), 230)
Exemplo n.º 8
0
 def test_get_string1_voltage(self):
     p = Piko(host='http://example.com')
     self.assertEqual(p.get_string1_voltage(), 384)
Exemplo n.º 9
0
 def test_get_daily_energy(self):
     p = Piko(host='http://example.com')
     self.assertEqual(p.get_daily_energy(), 19.83)
Exemplo n.º 10
0
 def test_get_total_energy(self):
     p = Piko(host='http://example.com')
     self.assertEqual(p.get_total_energy(), 9290)
Exemplo n.º 11
0
 def test_get_current_power(self):
     p = Piko(host='http://example.com')
     self.assertEqual(p.get_current_power(), 112)
Exemplo n.º 12
0
 def test_get_raw_content(self):
     p = Piko(host='http://example.com')
     self.assertEqual(p._get_raw_content(), [
         '112', '9290', '19.83', '384', '230', '0.20', '0', '278', '232',
         '0.21', '112', '0', '230', '0.00', '0'
     ])