al-one / hass-xiaomi-miot

Automatic integrate all Xiaomi devices to HomeAssistant via miot-spec, support Wi-Fi, BLE, ZigBee devices. 小米米家智能家居设备接入Hass集成
https://miot-spec.com
Apache License 2.0
4.55k stars 642 forks source link

请问怎么每天重载一次设备? #176

Closed jifengmm closed 3 years ago

jifengmm commented 3 years ago

我发现时间长了不重载,设备的状态的显示和米家App的不一致,不知道什么原因,手动重载一下就行了,我想弄成自动的,比如每天凌晨2点重载一次

al-one commented 3 years ago

可以通过HA服务:homeassistant.reload_config_entry 来重载集成配置:

service: homeassistant.reload_config_entry
target:
  entity_id: sensor.xiaomi_miot_entity_id # 任意属于该集成配置的实体ID

官方文档

al-one commented 3 years ago

关于设备实体状态和米家不一致的情况,是单个设备还是所有设备?可以观察下实体状态属性以及HA日志,也可以提交一个新的issue来报告此问题。

jifengmm commented 3 years ago

image 看了下日志,好像是更新数据失败了?会不会是我家网络连接小米云服务慢的原因? 但是这个是警告不是错误,是不是其实也更新状态成功了的?

jifengmm commented 3 years ago

你上面提到的重载的服务,比如我有20个设备接入了小米集成,是不是entity_id我只要写任意一个就能重载整个集成了?

al-one commented 3 years ago

你上面提到的重载的服务,比如我有20个设备接入了小米集成,是不是entity_id我只要写任意一个就能重载整个集成了?

是的,任意一个实体ID就可以。

看了下日志,好像是更新数据失败了?会不会是我家网络连接小米云服务慢的原因?

日志显示链接米家接口失败了,请在下次出现时检查网络情况,并测试HA所在主机能否访问小米接口:

curl -v https://api.io.mi.com
jifengmm commented 3 years ago

@al-one 好的谢谢,让我联想到最近小爱同学变得智障了,经常提示连不上服务器。不知道是不是我部署了网心云的问题,吃满了上传带宽。。。

jifengmm commented 3 years ago

image

@al-one 今天又出现状态不对了

al-one commented 3 years ago

请提供下日志。

jifengmm commented 3 years ago

image

这样的日志吗 @al-one image

这个是上面点开来的

Logger: root Source: /usr/local/lib/python3.8/site-packages/micloud/micloud.py:317 First occurred: 2021年9月1日 19:51:37 (41294 occurrences) Last logged: 15:27:41

Error while executing request to https://api.io.mi.com/app/miotspec/prop/get :HTTPSConnectionPool(host='api.io.mi.com', port=443): Max retries exceeded with url: /app/miotspec/prop/get (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1125)'))) Error while executing request to https://api.io.mi.com/app/miotspec/prop/set :HTTPSConnectionPool(host='api.io.mi.com', port=443): Max retries exceeded with url: /app/miotspec/prop/set (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1125)'))) Error while executing request to https://api.io.mi.com/app/user/get_user_device_data :HTTPSConnectionPool(host='api.io.mi.com', port=443): Max retries exceeded with url: /app/user/get_user_device_data (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1125)'))) Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen httplib_response = self._make_request( File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 382, in _make_request self._validate_conn(conn) File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn conn.connect() File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 411, in connect self.sock = ssl_wrapsocket( File "/usr/local/lib/python3.8/site-packages/urllib3/util/ssl.py", line 449, in ssl_wrap_socket ssl_sock = _ssl_wrap_socketimpl( File "/usr/local/lib/python3.8/site-packages/urllib3/util/ssl.py", line 493, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) File "/usr/local/lib/python3.8/ssl.py", line 500, in wrap_socket return self.sslsocket_class._create( File "/usr/local/lib/python3.8/ssl.py", line 1040, in _create self.do_handshake() File "/usr/local/lib/python3.8/ssl.py", line 1309, in do_handshake self._sslobj.do_handshake() ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1125)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send resp = conn.urlopen( File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen retries = retries.increment( File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 574, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.io.mi.com', port=443): Max retries exceeded with url: /app/miotspec/prop/get (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1125)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/micloud/micloud.py", line 306, in request response = self.session.post(url, data = post_data) File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 590, in post return self.request('POST', url, data=data, json=json, kwargs) File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 655, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 514, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='api.io.mi.com', port=443): Max retries exceeded with url: /app/miotspec/prop/get (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1125)')))

al-one commented 3 years ago

日志显示还是连接小米接口失败了。