コード例 #1
0
def _scan_network_for_devices(hass, call):
    import homeassistant.ais_dom.sensor.ais_device_search_mqtt as dsm
    global GLOBAL_X
    GLOBAL_MY_IP = ais_global.get_my_global_ip()
    info = ""
    if GLOBAL_X == 0:
        GLOBAL_X += 1
        # clear the value
        dsm.MQTT_DEVICES = []
        dsm.NET_DEVICES = []
        dsm.DOM_DEVICES = []
        hass.states.async_set(
            'sensor.network_devices_info_value', '',
            {'text': 'wykrywam, to może potrwać kilka minut...'})

        # send the message to all robots in network
        yield from hass.services.async_call('mqtt', 'publish', {
            'topic': 'cmnd/dom/status',
            'payload': 0
        })
        # fix for new robots, Tasmota 6.4.0
        yield from hass.services.async_call('mqtt', 'publish', {
            'topic': 'dom/cmnd/status',
            'payload': 0
        })
        # disco
        yield from hass.services.async_call('mqtt', 'publish', {
            'topic': 'dom/cmnd/SetOption19',
            'payload': 1
        })

        yield from hass.services.async_call('ais_shell_command',
                                            'scan_network_for_devices')
    # 256
    elif 0 < GLOBAL_X < 256:
        GLOBAL_X += 1
        rest_url = "http://{}.{}/cm?cmnd=status"
        url = rest_url.format(GLOBAL_MY_IP.rsplit('.', 1)[0], str(GLOBAL_X))
        info = "Sprawdzam " + GLOBAL_MY_IP.rsplit('.', 1)[0]
        info += "." + str(GLOBAL_X) + "\n"
        info += dsm.get_text()
        hass.states.async_set('sensor.network_devices_info_value', '',
                              {'text': info})

        # search android devices
        rest_url_a = "http://{}.{}:8122"
        url_a = rest_url_a.format(
            GLOBAL_MY_IP.rsplit('.', 1)[0], str(GLOBAL_X))

        yield from hass.services.async_call('ais_shell_command', 'scan_device',
                                            {
                                                "url": url,
                                                "url_a": url_a
                                            })

    else:
        GLOBAL_X = 0
        hass.states.async_set('sensor.network_devices_info_value', '',
                              {'text': dsm.get_text()})
コード例 #2
0
def _scan_network_for_devices(hass, call):
    import homeassistant.ais_dom.sensor.ais_device_search_mqtt as dsm
    global GLOBAL_X
    GLOBAL_MY_IP = ais_global.get_my_global_ip()
    info = ""
    if (GLOBAL_X == 0):
        GLOBAL_X += 1
        # clear the value
        dsm.MQTT_DEVICES = []
        dsm.NET_DEVICES = []
        dsm.DOM_DEVICES = []
        # dsm.NET_DEVICES.append("*Twoje IP, " + GLOBAL_MY_IP)
        hass.states.async_set(
            'sensor.network_devices_info_value', '', {
                'custom_ui_state_card': 'state-card-robot-disco',
                'text': '*wykrywam, to może potrwać kilka minut...'
            })

        # send the message to all robots in network
        yield from hass.services.async_call('mqtt', 'publish', {
            'topic': 'cmnd/dom/status',
            'payload': 0
        })
        yield from hass.services.async_call('ais_shell_command',
                                            'scan_network_for_devices')
    # 256
    elif (GLOBAL_X > 0 and GLOBAL_X < 256):
        GLOBAL_X += 1
        rest_url = "http://{}.{}/cm?cmnd=status"
        url = rest_url.format(GLOBAL_MY_IP.rsplit('.', 1)[0], str(GLOBAL_X))
        info = "!sprawdzam " + GLOBAL_MY_IP.rsplit('.', 1)[0]
        info += "." + str(GLOBAL_X) + "\n"
        info += dsm.get_text()
        hass.states.async_set('sensor.network_devices_info_value', '', {
            'custom_ui_state_card': 'state-card-robot-disco',
            'text': info
        })

        # search android devices
        rest_url_a = "http://{}.{}:8122"
        url_a = rest_url_a.format(
            GLOBAL_MY_IP.rsplit('.', 1)[0], str(GLOBAL_X))

        yield from hass.services.async_call('ais_shell_command', 'scan_device',
                                            {
                                                "url": url,
                                                "url_a": url_a
                                            })

    else:
        GLOBAL_X = 0
        hass.states.async_set(
            'sensor.network_devices_info_value', '', {
                'custom_ui_state_card': 'state-card-robot-disco',
                'text': dsm.get_text()
            })
コード例 #3
0
 def bg_cb_a(sess, resp):
     try:
         # parse the json storing the result on the response object
         json_ws_resp = resp.json()
         model = json_ws_resp["Model"]
         manufacturer = json_ws_resp["Manufacturer"]
         ip = json_ws_resp["IPAddressIPv4"]
         mac = json_ws_resp["MacWlan0"]
         dsm.DOM_DEVICES.append("#" + model + " " + manufacturer +
                                ", https://" + ip + ':8123')
         info = dsm.get_text()
         hass.states.async_set('sensor.network_devices_info_value', '', {
             'custom_ui_state_card': 'state-card-robot-disco',
             'text': info
         })
         # add the device to the speakers lists
         hass.async_add_job(
             hass.services.async_call(
                 'ais_cloud', 'get_players', {
                     'device_name':
                     model + " " + manufacturer + "(" + ip + ")",
                     CONF_IP_ADDRESS: ip,
                     CONF_MAC: mac
                 }))
     except Exception:
         pass
コード例 #4
0
def _show_network_devices_info(hass, call):
    import homeassistant.ais_dom.sensor.ais_device_search_mqtt as dsm
    info = dsm.get_text()
    hass.states.async_set('sensor.network_devices_info_value', '', {
        'custom_ui_state_card': 'state-card-robot-disco',
        'text': info
    })
コード例 #5
0
 def bg_cb(resp, *args, **kwargs):
     try:
         # parse the json storing the result on the response object
         json_ws_resp = resp.json()
         hostname = urlparse(resp.url).hostname
         name = json_ws_resp["Status"]["FriendlyName"][0]
         # ip = json_ws_resp["StatusNET"]["IPAddress"]
         dsm.NET_DEVICES.append("- " + name + ", http://" + hostname)
         info = dsm.get_text()
         hass.states.async_set('sensor.network_devices_info_value', '',
                               {'text': info})
     except Exception:
         pass
コード例 #6
0
 def bg_cb(sess, resp):
     try:
         # parse the json storing the result on the response object
         json_ws_resp = resp.json()
         hostname = urlparse(resp.url).hostname
         name = json_ws_resp["Status"]["FriendlyName"][0]
         #ip = json_ws_resp["StatusNET"]["IPAddress"]
         dsm.NET_DEVICES.append("#" + name + ", http://" + hostname + ':80')
         info = dsm.get_text()
         hass.states.async_set('sensor.network_devices_info_value', '', {
             'custom_ui_state_card': 'state-card-robot-disco',
             'text': info
         })
     except Exception:
         pass
コード例 #7
0
def _show_network_devices_info(hass, call):
    import homeassistant.ais_dom.sensor.ais_device_search_mqtt as dsm
    info = dsm.get_text()
    hass.states.async_set('sensor.network_devices_info_value', 'ok',
                          {'text': info})