cnk700i / havcs Goto Github PK
View Code? Open in Web Editor NEWHome Assistant Voice Control Skill
Home Page: https://ljr.im/articles/plugins-havcs-edible-instructions/
License: Apache License 2.0
Home Assistant Voice Control Skill
Home Page: https://ljr.im/articles/plugins-havcs-edible-instructions/
License: Apache License 2.0
rt
这样大家更新就方便了
HomeAssitant版本是:2022.6.6
HAVCS插件设置如下:
{
"platform": [
"dueros"
],
"http": {
"clients": {
"duerosdemo": "xxxx"
},
"ha_url": "http://127.0.0.1:8123",
"expire_in_hours": 87600
},
"device_config": "ui"
}
小度授权成功后,30分钟左右提示需要重新登录,重新授权后正常。
重启授权的时候,打开日志后发现报错:
jwt.InvalidTokenError
并且日志有打印
[util] access_token[xxxxxxxx] is invalid, try another reauthorization on website
最终确定是havcs/util.py 第 98行 jwt.decode 方法报错,改为下面写法后正常:
# 原报错代码
#unverif_claims = jwt.decode(access_token, verify=False)
# 修复代码,注意代码对齐
unverif_claims = jwt.decode(access_token, options={"verify_signature": False})
重启HomeAssistant后正常,过期时间是expire_in_hours 设置的时间。
查看home-assistant/.storage/auth文件,在refresh_tokens里面可以看到小度的授权信息。
查看 access_token_expiration 时长(单位秒)
{
"id": "xxxxx",
"user_id": "xxxxx",
"client_id": "https://xiaodu.baidu.com",
"client_name": null,
"client_icon": null,
"token_type": "normal",
"created_at": "2022-06-23T18:02:42.880327+00:00",
"access_token_expiration": 315360000.0,
"token": "xxxx",
"jwt_key": "xxxxx",
"last_used_at": "2022-06-23T18:02:42.889879+00:00",
"last_used_ip": "127.0.0.1",
"credential_id": "xxxxx",
"version": "2022.6.6"
},
顺便提一下开启debug模式方法:
修改配置文件configuration.yaml,增加下面四行代码
logger:
default: error
logs:
custom_components.havcs: debug
0.97.0 之前正常,升级到 0.97.0 后未关注到此问题,0.97.1 时才发现不再出现那个成功启动的提示,使用音箱也无法控制设备,升级到 0.97.2 后问题依旧
配置:
aihome:
platform:
- dueros
skill:
sync: True
switch.tv_power:
friendly_name: 电视
icon: mdi:television
aihome_device: True
dueros_deviceType: 'SWITCH'
dueros_actions: ['turnOn', 'turnOff']
日志:
2019-08-14 22:29:39 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/Users/suisr/.homeassistant/custom_components/aihome/init.py", line 341, in async_report_device
if not entity.attributes.get('aihome_device', False):
AttributeError: 'NoneType' object has no attribute 'attributes'
需要配置产品,并且协议好像与官网给的也有差别
结合 https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/
实际操作成功了但是天猫说失败了,似乎sleep被cancel了导致报错
2020-09-07 04:00:34 INFO (SyncWorker_13) [custom_components.gree.climate] Setting HeatCoolType: 0
2020-09-07 04:00:34 INFO (SyncWorker_13) [custom_components.gree.climate] Setting TemRec: 0 2020-09-07 04:00:34 INFO (SyncWorker_13) [custom_components.gree.climate] Setting SvSt: 0 2020-09-07 04:00:34 INFO (SyncWorker_13) [custom_components.gree.climate] Setting SlpMod: 0
2020-09-07 04:00:34 INFO (SyncWorker_13) [custom_components.gree.climate] Done setting acOptions
2020-09-07 04:00:34 INFO (SyncWorker_13) [custom_components.gree.climate] Overwriting acOptions with new settings
2020-09-07 04:00:34 INFO (SyncWorker_13) [custom_components.gree.climate] Overwriting Pow: 1
2020-09-07 04:00:34 INFO (SyncWorker_13) [custom_components.gree.climate] Done overwriting acOptions
2020-09-07 04:00:34 INFO (SyncWorker_13) [custom_components.gree.climate] Start sending state to HVAC
2020-09-07 04:00:36 ERROR (MainThread) [custom_components.havcs.http] [http] handle fail: Traceback (most recent call last):
File "/var/lib/homeassistant/custom_components/havcs/http.py", line 56, in post
response = await self._hass.data[INTEGRATION][DATA_HAVCS_HANDLER][platform].handleRequest(json.loads(data), refresh_token)
File "/var/lib/homeassistant/custom_components/havcs/aligenie.py", line 188, in handleRequest
err_result, content = await self.process_control_command(data)
File "/var/lib/homeassistant/custom_components/havcs/helper.py", line 116, in process_control_command
result = await self._hass.services.async_call(domain_list[i], service_list[i], data_list[i], True)
File "/custom/mnt/data/var/lib/homeassistant/venv/lib/python3.8/site-packages/homeassistant/core.py", line 1293, in async_call
await asyncio.wait({task}, timeout=limit)
File "/usr/lib/python3.8/asyncio/tasks.py", line 426, in wait
File "/usr/lib/python3.8/asyncio/tasks.py", line 523, in _wait
asyncio.exceptions.CancelledError
2020-09-07 04:02:51 ERROR (MainThread) [custom_components.havcs.http] [http] handle fail: Traceback (most recent call last):
File "/var/lib/homeassistant/custom_components/havcs/http.py", line 56, in post
response = await self._hass.data[INTEGRATION][DATA_HAVCS_HANDLER][platform].handleRequest(json.loads(data), refresh_token)
File "/var/lib/homeassistant/custom_components/havcs/aligenie.py", line 188, in handleRequest
err_result, content = await self.process_control_command(data)
File "/var/lib/homeassistant/custom_components/havcs/helper.py", line 129, in process_control_command
await asyncio.sleep(1)
File "/usr/lib/python3.8/asyncio/tasks.py", line 648, in sleep
asyncio.exceptions.CancelledError
sleep 被别的 signal 唤醒了所以提前返回?
以下例子示范原理
# sleep 100 &
[1] 23639
# killall -USR1 sleep
[1]+ User defined signal 1 sleep 100
Logger: custom_components.havcs
Source: custom_components/havcs/init.py:642
Integration: Home Assistant Voice Control Skill (documentation)
First occurred: 下午11:06:15 (1 occurrences)
Last logged: 下午11:06:15
[post-task] Unable to import havcs.dueros, cannot import name 'AsyncTrackStates' from 'homeassistant.helpers.state' (/usr/src/homeassistant/homeassistant/helpers/state.py)
天猫官方支持很多传感器
最好是可以设定一个传感器映射选项,这样就能自己增加天猫所支持查询的传感器。
比如我有一个光线传感器,但是ha里生成的是sensor.xxx.light 和 brightness不对应,这时候设置light映射为brightness就可以支持这个传感器查询了。hcho映射到fog同理。
甲醛可以改为 fog/雾 的查询。
其他映射规则也可以另类支持不少其他传感器的查询了。比如土壤肥度等等的查询。
HA 版本 111.2,日志报错:Detected use of deprecated base_url
property
Logger: homeassistant.components.http
Source: components/http/__init__.py:180
Integration: HTTP (documentation, issues)
First occurred: 上午10:30:04 (3 occurrences)
Last logged: 上午10:30:04
Detected use of deprecated `base_url` property, use `homeassistant.helpers.network.get_url` method instead. Please report issue to the custom component author for havcs using this method at custom_components/havcs/__init__.py, line 250: http_manager = hass.data[DOMAIN][DATA_HAVCS_HTTP_MANAGER] = HavcsHttpManager(hass, conf.get(CONF_HTTP, {}).get(CONF_HA_URL, hass.config.api.base_url), DEVICE_CONFIG_SCHEMA)
Detected use of deprecated `base_url` property, use `homeassistant.helpers.network.get_url` method instead. Please report issue to the custom component author for havcs using this method at custom_components/havcs/__init__.py, line 306: ha_url = conf.get(CONF_HTTP, {}).get(CONF_HA_URL, hass.config.api.base_url)
Detected use of deprecated `base_url` property, use `homeassistant.helpers.network.get_url` method instead. Please report issue to the custom component author for havcs using this method at custom_components/havcs/__init__.py, line 307: _LOGGER.debug("[init] ha_url = %s, base_url = %s", ha_url, hass.config.api.base_url)
havcs 的yaml里面,ha_url按照升级111.2以前设置为 https://localhost:8123,
目前不能正常使用,web界面点开套娃,不知道是不是这个原因造成的
一定需要https 证书吗?我公网 域名 docker啥都有,唯独没证书
这样可以获取人体传感器,门窗开关的状态.
小度音箱 + HA 0.104.2
升级之前无法控制设备,提示请检查服务,于是升级
升级完成之后,依然无法控制设备,提示请检查服务
尝试解除授权,重新授权,然后使用“发现设备”命令,提示 无法找到设备
启动 HA 后,havcs 相关日志如下:
2020-01-18 23:26:26 INFO (MainThread) [custom_components.havcs] [init] havcs run with "skill mode"(mode 3)
2020-01-18 23:26:26 DEBUG (MainThread) [custom_components.havcs.helper] [bindManager] ----init bindManager----
2020-01-18 23:26:26 DEBUG (MainThread) [custom_components.havcs.helper] [bindManager] discovery:
['7da44ebb784c814dfaa4ef68ff75f5bb@dueros']
2020-01-18 23:26:26 INFO (MainThread) [custom_components.havcs] [init] import havcs.dueros
2020-01-18 23:26:26 DEBUG (MainThread) [custom_components.havcs] [init] sucess to autoload ca.crt from /Users/suisr/.homeassistant/custom_components/havcs/ca.crt
2020-01-18 23:26:26 INFO (MainThread) [custom_components.havcs] [init] initialization finished, waiting for welcome message of mqtt server.
2020-01-18 23:26:56 INFO (MainThread) [custom_components.havcs] [init] load config after startup
2020-01-18 23:26:56 DEBUG (MainThread) [custom_components.havcs] [mqtt] -------- start handle task from mqtt at 2020-01-18 23:26:56 --------
2020-01-18 23:26:56 INFO (MainThread) [custom_components.havcs] [mqtt] get hello message:
****************************************************
***欢迎使用"havcs智能音箱接入Home Assistant方案"***
*********当你看到此信息,说明mqtt已正常工作*********
****************************************************
2020-01-18 23:26:56 DEBUG (MainThread) [custom_components.havcs] [mqtt] -------- mqtt task finish at 2020-01-18 23:26:56, Running time: 0.006419s --------
调用 havcs.reload 服务后,显示如下:
2020-01-18 23:50:58 INFO (MainThread) [custom_components.havcs] [service] ------------dueros 平台加载设备信息------------
[{'entity_id': 'switch.tv_power', 'device_type': 'SWITCH', 'device_name': '电视', 'zone': '客厅', 'properties': [{'entity_id': 'switch.tv_power', 'attribute': 'power_state'}], 'actions': ['turn_on', 'turn_off']}, {'entity_id': 'switch.tv_pause', 'device_type': 'SWITCH', 'device_name': '暂停电视', 'zone': '客厅', 'properties': [{'entity_id': 'switch.tv_pause', 'attribute': 'power_state'}], 'actions': ['turn_on', 'turn_off']}, {'entity_id': 'switch.guest_wifi', 'device_type': 'SWITCH', 'device_name': '访客网络', 'zone': '客厅', 'properties': [{'entity_id': 'switch.guest_wifi', 'attribute': 'power_state'}], 'actions': ['turn_on', 'turn_off']}]
版本 | core-2021.3.2 |
---|---|
安装类型 | Home Assistant OS |
2021-03-06 11:36:27 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry 主配置[Web界面] for havcs
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 248, in async_setup
result = await component.async_setup_entry(hass, self) # type: ignore
File "/config/custom_components/havcs/init.py", line 254, in async_setup_entry
http_manager = hass.data[DOMAIN][DATA_HAVCS_HTTP_MANAGER] = HavcsHttpManager(hass, conf.get(CONF_HTTP, {}).get(CONF_HA_URL, get_url(hass)), DEVICE_CONFIG_SCHEMA, SETTINGS_CONFIG_SCHEMA)
File "/usr/src/homeassistant/homeassistant/helpers/network.py", line 84, in get_url
request_host = _get_request_host()
File "/usr/src/homeassistant/homeassistant/helpers/network.py", line 124, in _get_request_host
raise NoURLAvailableError
homeassistant.helpers.network.NoURLAvailableError
[http][auth] fail to get token, access http://192.168.0.24:8123/auth/token in local network: Traceback (most recent call last): File "/config/custom_components/havcs/http.py", line 220, in post with async_timeout.timeout(5, loop=self._hass.loop): TypeError: timeout() got an unexpected keyword argument 'loop'
外网https访问正常,ddns--路由器---nginx反向代理---homeassis,在百度技能平台授权一直提示失败。homeassis报上述错误。
直接判断entity_id是否含有pm2.5,但是Home Assistant会自动把 . 替换成 _ 。会报错找不到。所以应该判断entity_id是否含有pm2
小度无法使用 ipv6 进行控制
暂时不确定是插件的问题 还是 小度平台的问题
nginx 设置不使用 ipv6 后 正常
使用 http 模式 有公网 ip
nginx 反向代理 8123 -> 127.0.0.1:8124
经测试可以正常使用
使用 nginx 进行反向代理 ha 功能均正常
在技能平台进行授权时出现错误 提示 授权失败
经过数天的调试,发现协议已经变了,新注册精灵服务已经默认使用aligenie.iot 2.0协议,插件不兼容,附官方文档地址:https://www.yuque.com/qw5nze/ga14hc/cmhq2c
Logger: homeassistant.config_entries
Source: custom_components/havcs/init.py:250
First occurred: 上午11:16:47 (1 occurrences)
Last logged: 上午11:16:47
Error setting up entry 主配置[configuration.yml] for havcs
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 248, in async_setup
result = await component.async_setup_entry(hass, self) # type: ignore
File "/config/custom_components/havcs/init.py", line 250, in async_setup_entry
http_manager = hass.data[DOMAIN][DATA_HAVCS_HTTP_MANAGER] = HavcsHttpManager(hass, conf.get(CONF_HTTP, {}).get(CONF_HA_URL, hass.config.api.base_url), DEVICE_CONFIG_SCHEMA)
AttributeError: 'ApiConfig' object has no attribute 'base_url'
升级了HA 和 HAVCS V3.发现有error,请大神帮忙看下。谢谢。
Home Assistant 0.113.2
Log Details (ERROR)
Logger: homeassistant.config_entries
Source: custom_components/havcs/init.py:372
First occurred: 10:23:49 PM (1 occurrences)
Last logged: 10:23:49 PM
Error setting up entry configuration.yaml for havcs
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 219, in async_setup
result = await component.async_setup_entry( # type: ignore
File "/config/custom_components/havcs/init.py", line 372, in async_setup_entry
hass.data[DOMAIN][DATA_HAVCS_MQTT] = mqtt.MQTT(
TypeError: init() got an unexpected keyword argument 'broker'
版本:havcs v3
模式:模式一 http模式,自建测试技能
环境:内网http访问,外网通过nginx代理,通过https访问
平台:dueros
网络条件:移动宽带,无ipv4公网ip,但外网可通过ipv6访问
按教程部署havcs v3后,无论使用HA自带的授权页面还是havcs授权页面,dueros开放平台均授权失败。
使用另一台具有公网ipv4的服务器,运行nginx,通过ipv6访问HA主机并反向代理,对外提供基于ipv4的https服务,即可授权成功。
建议:解决纯ipv6环境的授权问题。
谢谢
第一次通过code来换取token是有refresh_token值,但是通过refresh_token请求来刷新token返回没有refresh_token的值,导致天猫精灵的授权过期,需要重新进入测试验证,请问该如何配置
请求https://xxx.com/havcs_auth grant_type=authorization_code 有refresh_token值
请求https://xxx.com/havcs_auth grant_type=refresh_token 没有refresh_token值
2020-09-07 13:15:26 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for havcs doing I/O at custom_components/havcs/aligenie.py, line 148: self._zone_constraints = json.loads(urlopen('https://open.bot.tmall.com/oauth/api/placelist').read().decode('utf-8'))['data']
2020-09-07 13:15:26 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for havcs doing I/O at custom_components/havcs/aligenie.py, line 149: self._device_name_constraints = json.loads(urlopen('https://open.bot.tmall.com/oauth/api/aliaslist').read().decode('utf-8'))['data']
home assistant玩智能家居的群组有分享的吗?
Logger: homeassistant.config_entries
Source: helpers/network.py:123
First occurred: 23:40:44 (1 occurrences)
Last logged: 23:40:44
Error setting up entry 主配置[configuration.yml] for havcs
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 293, in async_setup
result = await component.async_setup_entry(hass, self) # type: ignore
File "/config/custom_components/havcs/init.py", line 254, in async_setup_entry
http_manager = hass.data[DOMAIN][DATA_HAVCS_HTTP_MANAGER] = HavcsHttpManager(hass, conf.get(CONF_HTTP, {}).get(CONF_HA_URL, get_url(hass)), DEVICE_CONFIG_SCHEMA, SETTINGS_CONFIG_SCHEMA)
File "/usr/src/homeassistant/homeassistant/helpers/network.py", line 83, in get_url
request_host = _get_request_host()
File "/usr/src/homeassistant/homeassistant/helpers/network.py", line 123, in _get_request_host
raise NoURLAvailableError
homeassistant.helpers.network.NoURLAvailableError
__INFO:
是因为ha_url通过HA内置方法自动识别时,由于新版HA会优先读取旧版本.storage/core.config的url配置,可能会因此导致不准确。_怎么解?
大佬,模式一为什么一段时间就提示智能家居控制暂时使用不了啊?
点击保存,就报错:增加失败!
但是,刷新界面,又能看到AppKey
接着去HomeAssistant配置,又提示”未授权“
然后等了1个小时,还是提示未授权
<发现设备>命令提示无法找到设备,但是app中可以看到设备。
语音或通过app控制设备时插件报错。
configuration.yaml
havcs:
platform:
- dueros
- jdwhale
http:
ha_url: https://xxx.xxxxx.com
expire_in_hours: 24000
havcs.yaml
light.kitchen:
havcs_device_name: 厨房灯
havcs_zone: 厨房
havcs_device_type: light
havcs_actions: ['turn_on', 'turn_off', 'timing_turn_on', 'timing_turn_off']
havcs.reload
2020-01-22 11:07:51 INFO (MainThread) [custom_components.havcs] [service] ------------dueros 平台加载设备信息------------,
[{'entity_id': 'light.kitchen', 'device_type': 'LIGHT', 'device_name': '厨房灯', 'zone': '厨房', 'properties': [{'entity_id': 'light.kitchen', 'attribute': 'power_state'}], 'actions': ['turn_on', 'turn_off', 'timing_turn_on', 'timing_turn_off']}]
<发现设备>
2020-01-22 10:47:44 DEBUG (MainThread) [custom_components.havcs] [http] raw message: {"header":{"payloadVersion":"1","name":"DiscoverAppliancesRequest","namespace":"DuerOS.ConnectedHome.Discovery","messageId":"13742062af2741cfbf55c0f4375a16a8_DCS-10-201-43-32-8260-0122104742-2919622_0#1_0_Smarthome_5e27b7cfcd4285.79138016"},"payload":{"accessToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIwYWFjZDQyZDY4MGY0ZTc2YWYzOTJkN2ZjY2NjNzg3MSIsImlhdCI6MTU3OTYxMjQxNiwiZXhwIjoxNTc5Njk4ODE2fQ.FJmy2S3dj537hAopgaDEWkYUlPp72Z0N3TchA1MaF_Y","openUid":"f0736c30e4d9ad9cacde4211323d80cc"}},
2020-01-22 10:47:44 DEBUG (MainThread) [custom_components.havcs] [http] -------- start handle task from http at 2020-01-22 10:47:44 --------,
2020-01-22 10:47:44 DEBUG (MainThread) [custom_components.havcs] [http] get access_token >>> eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIwYWFjZDQyZDY4MGY0ZTc2YWYzOTJkN2ZjY2NjNzg3MSIsImlhdCI6MTU3OTYxMjQxNiwiZXhwIjoxNTc5Njk4ODE2fQ.FJmy2S3dj537hAopgaDEWkYUlPp72Z0N3TchA1MaF_Y <<<,
{'header': {'payloadVersion': '1', 'name': 'DiscoverAppliancesRequest', 'namespace': 'DuerOS.ConnectedHome.Discovery', 'messageId': '13742062af2741cfbf55c0f4375a16a8_DCS-10-201-43-32-8260-0122104742-2919622_0#1_0_Smarthome_5e27b7cfcd4285.79138016'}, 'payload': {'accessToken': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIwYWFjZDQyZDY4MGY0ZTc2YWYzOTJkN2ZjY2NjNzg3MSIsImlhdCI6MTU3OTYxMjQxNiwiZXhwIjoxNTc5Njk4ODE2fQ.FJmy2S3dj537hAopgaDEWkYUlPp72Z0N3TchA1MaF_Y', 'openUid': 'f0736c30e4d9ad9cacde4211323d80cc'}},
2020-01-22 10:47:44 DEBUG (MainThread) [custom_components.havcs] [http] validate access_token, get refresh_token(id = 0aacd42d680f4e76af392d7fcccc7871),
2020-01-22 10:47:44 INFO (MainThread) [custom_components.havcs.dueros] [dueros] Handle Request:,
2020-01-22 10:47:44 INFO (MainThread) [custom_components.havcs.dueros] [dueros] Respnose:,
{'header': {'payloadVersion': '1', 'name': 'DiscoverAppliancesResponse', 'namespace': 'DuerOS.ConnectedHome.Discovery', 'messageId': '13742062af2741cfbf55c0f4375a16a8_DCS-10-201-43-32-8260-0122104742-2919622_0#1_0_Smarthome_5e27b7cfcd4285.79138016'}, 'payload': {'discoveredAppliances': [{'applianceId': 'light.kitchen', 'friendlyName': '厨房灯', 'friendlyDescription': '厨房灯', 'additionalApplianceDetails': [], 'applianceTypes': ['LIGHT'], 'isReachable': True, 'manufacturerName': 'HomeAssistant', 'modelName': 'HomeAssistant', 'version': '1.0', 'actions': ['turnOff', 'turnOn', 'timingTurnOff', 'timingTurnOn'], 'attributes': [{'name': 'turnOnState', 'value': 'OFF', 'scale': '', 'timestampOfSample': 1579661264, 'uncertaintyInMilliseconds': 1000, 'legalValue': '(ON, OFF)'}]}]}},
2020-01-22 10:47:44 DEBUG (MainThread) [custom_components.havcs] [http] -------- http task finish at 2020-01-22 10:47:44, running time: 0.014139s --------
<打开客厅灯>
2020-01-22 10:53:34 DEBUG (MainThread) [custom_components.havcs] [http] -------- start handle task from http at 2020-01-22 10:53:34 --------,
2020-01-22 10:53:34 DEBUG (MainThread) [custom_components.havcs] [http] raw message: {"header":{"payloadVersion":"1","messageId":"7cecfdc7128141c4976ee90f41bd95df_DCS-10-201-42-32-8230-0122105333-3060678_0#1_0_Smarthome_5e27b92e918925.76802714","name":"TurnOnRequest","namespace":"DuerOS.ConnectedHome.Control"},"payload":{"accessToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIwYWFjZDQyZDY4MGY0ZTc2YWYzOTJkN2ZjY2NjNzg3MSIsImlhdCI6MTU3OTYxMjQxNiwiZXhwIjoxNTc5Njk4ODE2fQ.FJmy2S3dj537hAopgaDEWkYUlPp72Z0N3TchA1MaF_Y","appliance":{"additionalApplianceDetails":{},"applianceId":"light.kitchen"}}},
2020-01-22 10:53:34 DEBUG (MainThread) [custom_components.havcs] [http] get access_token >>> eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIwYWFjZDQyZDY4MGY0ZTc2YWYzOTJkN2ZjY2NjNzg3MSIsImlhdCI6MTU3OTYxMjQxNiwiZXhwIjoxNTc5Njk4ODE2fQ.FJmy2S3dj537hAopgaDEWkYUlPp72Z0N3TchA1MaF_Y <<<,
2020-01-22 10:53:34 DEBUG (MainThread) [custom_components.havcs] [http] validate access_token, get refresh_token(id = 0aacd42d680f4e76af392d7fcccc7871),
2020-01-22 10:53:34 INFO (MainThread) [custom_components.havcs.dueros] [dueros] Handle Request:,
{'header': {'payloadVersion': '1', 'messageId': '7cecfdc7128141c4976ee90f41bd95df_DCS-10-201-42-32-8230-0122105333-3060678_0#1_0_Smarthome_5e27b92e918925.76802714', 'name': 'TurnOnRequest', 'namespace': 'DuerOS.ConnectedHome.Control'}, 'payload': {'accessToken': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIwYWFjZDQyZDY4MGY0ZTc2YWYzOTJkN2ZjY2NjNzg3MSIsImlhdCI6MTU3OTYxMjQxNiwiZXhwIjoxNTc5Njk4ODE2fQ.FJmy2S3dj537hAopgaDEWkYUlPp72Z0N3TchA1MaF_Y', 'appliance': {'additionalApplianceDetails': {}, 'applianceId': 'light.kitchen'}}},
2020-01-22 10:53:34 ERROR (MainThread) [custom_components.havcs] [http] handle fail: Traceback (most recent call last):,
File "/config/custom_components/havcs/__init__.py", line 657, in post,
response = await HANDLER[platform].handleRequest(json.loads(data), refresh_token),
File "/config/custom_components/havcs/dueros.py", line 196, in handleRequest,
err_result, properties = await self.process_control_command(data),
File "/config/custom_components/havcs/helper.py", line 67, in process_control_command,
entity_id = self._decrypt_device_id(device_id),
File "/config/custom_components/havcs/dueros.py", line 327, in _decrypt_device_id,
return decrypt_device_id(device_id),
File "/config/custom_components/havcs/util.py", line 64, in decrypt_device_id,
return entity_id,
UnboundLocalError: local variable 'entity_id' referenced before assignment,
,
2020-01-22 10:53:34 DEBUG (MainThread) [custom_components.havcs] [http] -------- http task finish at 2020-01-22 10:53:34, running time: 0.0263s --------
平台模拟测试请求和响应
平台模拟测试请求和响应-发现设备.txt
平台模拟测试请求和响应-控制设备.txt
ai-home 网页打不开了,无法注册和添加
添加集成时提示未搜索到相关集成,可能是您要配置的集成还不支持通过 UI 配置。
更多可用信息,尽在 Home Assistant 网站.文件配置因版本不同也和说明文件不一致。
不能注册账号了是怎么回事?
启动日志如下
`2021-08-21 18:47:22 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration havcs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-08-21 18:47:22 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-08-21 18:47:28 INFO (MainThread) [custom_components.havcs] [init] havcs enable "http mode"
2021-08-21 18:47:28 DEBUG (MainThread) [custom_components.havcs] [init] havcs only run in http mode, skip mqtt initialization
2021-08-21 18:47:28 DEBUG (MainThread) [custom_components.havcs] [init] ha_url = https://localhost:8123, base_url = https://localhost:8123
2021-08-21 18:47:28 INFO (MainThread) [custom_components.havcs] [init] havcs initialization finished.
2021-08-21 18:47:32 INFO (MainThread) [custom_components.havcs] loading settings from file
2021-08-21 18:47:32 DEBUG (MainThread) [custom_components.havcs] [post-task] load new platform entry set()
2021-08-21 18:47:32 DEBUG (MainThread) [custom_components.havcs] [post-task] remove old platform entry set()
2021-08-21 18:47:32 INFO (MainThread) [custom_components.havcs] [post-task] import havcs.dueros
2021-08-21 18:47:32 INFO (MainThread) [custom_components.havcs] loading device info from file
2021-08-21 18:47:32 DEBUG (MainThread) [custom_components.havcs.http] [http] check accessibility from local, base_url = https://localhost:8123
2021-08-21 18:47:32 INFO (MainThread) [custom_components.havcs] [service] ------------dueros 平台加载设备信息------------
[{'device_id': 'havcs.switch01', 'entity_id': ['switch.cha_zuo'], 'type': 'switch', 'name': 'xiaomi', 'zone': 'Bedroom', 'properties': [{'entity_id': 'switch.cha_zuo', 'attribute': 'power_state'}], 'actions': ['turn_on', 'turn_off']}]
2021-08-21 18:47:32 INFO (MainThread) [custom_components.havcs] [service] ------------dueros 平台加载设备信息------------
2021-08-21 18:47:32 DEBUG (MainThread) [custom_components.havcs.http] [http][check] aouth service is running: url = https://localhost:8123/havcs/auth/authorize, status = 401
2021-08-21 18:47:35 ERROR (MainThread) [custom_components.hacs] tellerbop/havistapool - Repository is archived.`
是不是由于目前版本升级后,http接口哪块有问题
2021-12-08 23:10:53 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 314, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 546, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'invalid HTTP method'"
2021-12-08 23:10:59 DEBUG (MainThread) [custom_components.havcs] [mqtt] -------- start handle task from mqtt at 2021-12-08 23:10:59 --------
2021-12-08 23:10:59 DEBUG (MainThread) [custom_components.havcs] [mqtt] raw message: {'content': '{"extensions":{},"header":{"messageId":"86dd3311-d621-4519-8324-e37e933f5360","name":"DiscoveryDevices","namespace":"AliGenie.Iot.Device.Discovery","payLoadVersion":1},"payload":{"accessToken":"06e5c97696500cd1e6dea16464ddbea0477635f5"}}', 'headers': {'Authorization': 'Bearer 06e5c97696500cd1e6dea16464ddbea0477635f5'}, 'msgId': '7b823693c76dd99591544c518f7acf8e', 'platform': 'aligenie', 'msgType': 'cmnd'}
2021-12-08 23:10:59 INFO (MainThread) [custom_components.havcs.aligenie] [aligenie] Handle Request:
{'extensions': {}, 'header': {'messageId': '86dd3311-d621-4519-8324-e37e933f5360', 'name': 'DiscoveryDevices', 'namespace': 'AliGenie.Iot.Device.Discovery', 'payLoadVersion': 1}, 'payload': {'accessToken': '06e5c97696500cd1e6dea16464ddbea0477635f5'}}
2021-12-08 23:10:59 INFO (MainThread) [custom_components.havcs.aligenie] [aligenie] Respnose:
{'header': {'messageId': '86dd3311-d621-4519-8324-e37e933f5360', 'name': 'DiscoveryDevicesResponse', 'namespace': 'AliGenie.Iot.Device.Discovery', 'payLoadVersion': 1}, 'payload': {'devices': []}}
2021-12-08 23:10:59 DEBUG (MainThread) [custom_components.havcs] [mqtt] -------- mqtt task finish at 2021-12-08 23:10:59, Running time: 0.167872s --------
aihome是可以查询的(多传感器指温度+湿度,单给温度可以查询,加上湿度传感器报暂不支持多设备的查询)
但是havcs不行
应该是没有绑定为同一组的关系吧
另外好像没有实现pm25等传感器查询功能
解决了 不能新建 确实需要绑定到同一个项目下
删除aihome插件之后 并且注释掉configuration.yaml相应内容
但是一直重新生成aihome管理员
log对应会出现ERROR (MainThread) [homeassistant.setup] Setup failed for aihome: Integration not found.
这是还有残留?
从v2迁移到v3,使用http模式、公网ip或已实现内网穿透。
保持原来v2版本的configure文件不变,配置报错提示要配置clients:required key not provided @ data['havcs']['http']['clients']
按照教程配置clients如下:
havcs:
platform:
- dueros
http:
clients:
dueros001: 123456
ha_url: https://XXXXXXX
expire_in_hours: 24
device_config: ui
启动HA报错提示缺少mqtt。是说现在mqtt是必须的吗?还是我弄错了什么
async_get() missing 1 required positional argument: 'hass'
日志详细信息( ERROR )
Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/havcs/helper.py:265
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 10:35:08 (5 occurrences)
Last logged: 10:51:40
[140581625919632] async_get() missing 1 required positional argument: 'hass'
[140581835027408] async_get() missing 1 required positional argument: 'hass'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 205, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1965, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2005, in _execute_service
return await cast(
^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 930, in admin_handler
await result
File "/usr/src/homeassistant/homeassistant/components/homeassistant/init.py", line 339, in async_handle_reload_all
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/core.py", line 1965, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2005, in _execute_service
return await cast(
^^^^^^^^^^^
File "/config/custom_components/havcs/init.py", line 653, in async_handler_service
await hass.data[DOMAIN][DATA_HAVCS_HANDLER][platform].vcdm.async_reregister_devices(hass)
File "/config/custom_components/havcs/helper.py", line 265, in async_reregister_devices
device_registry = await hass.helpers.device_registry.async_get()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: async_get() missing 1 required positional argument: 'hass'
从aihome升级至havcs,原来按照aihome教程所写,通过group打包温度、湿度传感器成一个template sensor,配置customize.yaml后可以被dueros识别和查询。
更换havcs后,未寻获相关教程,自行尝试如下:
保持group.yaml、configuration.yaml中相关配置不变,删除customize.yaml中相关配置,在havcs.yaml中添加如下配置:
sensor.livingroom: #configuration.yaml中虚拟的template sensor
friendly_name: 客厅传感器
havcs_related_sensors: group.livingroom_sensors #group.yaml中打包的组
havcs_actions [‘query_temperature’, ‘query_humidity’]
测试结果不能被dueros识别。
请问该如何配置?
配置时出现问题:
Only a single configuration of HACS is allowed.
之前用的好好的,突然之间不能用了,抓日志提示信息如下:
2020-01-16 23:45:47 DEBUG (MainThread) [custom_components.havcs] [http] get access_token >>> get_user_access_token_empty <<< 2020-01-16 23:45:47 DEBUG (MainThread) [custom_components.havcs] [http] validate access_token, get None 2020-01-16 23:45:47 DEBUG (MainThread) [custom_components.havcs] [http] !!! token校验失败,请检查授权 !!!
Home Assistant 版本 0.103.6
此错误来自自定义集成。
Logger: custom_components.havcs
Source: custom_components/havcs/init.py:642
Integration: Home Assistant Voice Control Skill (documentation)
First occurred: 2023年8月29日 17:47:38 (1 occurrences)
Last logged: 2023年8月29日 17:47:38
[post-task] Unable to import havcs.aligenie, cannot import name 'AsyncTrackStates' from 'homeassistant.helpers.state' (/usr/src/homeassistant/homeassistant/helpers/state.py)
貌似是state.py修改了配置,有朋友遇到过相同问题不?该如何解决呢。。
2020-03-05 12:34:12 ERROR (MainThread) [custom_components.havcs] [skill] fail to access https://ai-home.ljr.im/skill/smarthome.php?v=update&AppKey=BZHdzve8mUcDGQr4, bind device fail: timeout
2020-08-31 16:18:03 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for havcs doing I/O at custom_components/havcs/aligenie.py, line 148: self._zone_constraints = json.loads(urlopen('https://open.bot.tmall.com/oauth/api/placelist').read().decode('utf-8'))['data']
2020-08-31 16:18:03 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for havcs doing I/O at custom_components/havcs/aligenie.py, line 149: self._device_name_constraints = json.loads(urlopen('https://open.bot.tmall.com/oauth/api/aliaslist').read().decode('utf-8'))['data']
ui无法显示设备,并且底下三个按钮点击无效,已清除缓存。
使用 猫精正常控制
Home assistant报错:
此错误来自自定义集成。
Logger: custom_components.havcs
Source: custom_components/havcs/__init__.py:394
Integration: Home Assistant Voice Control Skill (documentation)
First occurred: 19:46:56 (1 occurrences)
Last logged: 19:46:56
[init] fail to check whether ca.crt is latest, cause by TypeError("timeout() got an unexpected keyword argument 'loop'")
错误是这个pr导致的,很可惜我不会python...
home-assistant/core#65732 (comment)
请问这是怎么回事呢?
我的HA是0.93
输入用户名和密码后就一直这样。
···
2021-01-07 14:49:34 DEBUG (MainThread) [custom_components.havcs.helper] [helper] light.livingroom_main_light @task_0: domain = light, servcie = turn_on, data = {'brightness
_pct': 'min', 'entity_id': 'light.livingroom_main_light'}
2021-01-07 14:49:34 ERROR (MainThread) [custom_components.havcs.helper] [helper] light.livingroom_main_light @task_0: failed to call service
Traceback (most recent call last):
Traceback (most recent call last):
File "/var/lib/homeassistant/custom_components/havcs/helper.py", line 148, in process_control_command
result = await self._hass.services.async_call(domain_list[i], service_list[i], data_list[i], True)
File "/custom/mnt/data/var/lib/homeassistant/venv/lib/python3.8/site-packages/homeassistant/core.py", line 1399, in async_call
processed_data = handler.schema(service_data)
File "/custom/mnt/data/var/lib/homeassistant/venv/lib/python3.8/site-packages/voluptuous/validators.py", line 218, in call
return self._exec((Schema(val) for val in self.validators), v)
File "/custom/mnt/data/var/lib/homeassistant/venv/lib/python3.8/site-packages/voluptuous/validators.py", line 341, in _exec
raise e if self.msg is None else AllInvalid(self.msg, path=path)
File "/custom/mnt/data/var/lib/homeassistant/venv/lib/python3.8/site-packages/voluptuous/validators.py", line 337, in _exec
v = func(v)
File "/custom/mnt/data/var/lib/homeassistant/venv/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 272, in call
return self._compiled([], data)
File "/custom/mnt/data/var/lib/homeassistant/venv/lib/python3.8/site-packages/voluptuous/validators.py", line 215, in _run
return self._exec(self._compiled, value, path)
File "/custom/mnt/data/var/lib/homeassistant/venv/lib/python3.8/site-packages/voluptuous/validators.py", line 341, in _exec
raise e if self.msg is None else AllInvalid(self.msg, path=path)
File "/custom/mnt/data/var/lib/homeassistant/venv/lib/python3.8/site-packages/voluptuous/validators.py", line 339, in _exec
v = func(path, v)
File "/custom/mnt/data/var/lib/homeassistant/venv/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
return schema(data)
File "/custom/mnt/data/var/lib/homeassistant/venv/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 272, in call
return self._compiled([], data)
File "/custom/mnt/data/var/lib/homeassistant/venv/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
return base_validate(path, iteritems(data), out)
File "/custom/mnt/data/var/lib/homeassistant/venv/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: expected float for dictionary value @ data['brightness_pct']
···
天猫可能以前传递数值现在传递 min max 了。 看来 min max 得替换成别的才可以
home assistant 通过 homekit_controller 插件接上 Aqara 的网关(支持homekit),控制灯开关。
语音命令天猫精灵去关灯,结果控制不了。
看 log 是 aihome 插件 crash 了。
另外,后面的 log 显示好像 home_controller 更新状态时超时了。
2019-06-20 19:38:55 DEBUG (MainThread) [custom_components.aihome] [http] get access_token[eyJ...my_token...RSU]
2019-06-20 19:38:55 DEBUG (MainThread) [custom_components.aihome] [http] validate access_token, get refresh_token(id = d53...my_id_6e3)
2019-06-20 19:38:55 INFO (MainThread) [custom_components.aihome.aligenie] Handle Request: {'header': {'messageId': '39d...my_messageId...50b', 'name': 'Tur
nOff', 'namespace': 'AliGenie.Iot.Device.Control', 'payLoadVersion': 1}, 'payload': {'accessToken': 'eyJ...my_token....RSU', 'attribute': 'powerstate', 'deviceId': 'switch.
wall_switch_5855', 'deviceType': 'light', 'value': 'off'}}
2019-06-20 19:38:55 DEBUG (MainThread) [custom_components.aihome.aligenie] domain: switch, servcie: turn_off, data: {'entity_id': 'switch.wall_switch_5855'}
2019-06-20 19:38:57 ERROR (MainThread) [custom_components.aihome] [http] handle fail: Traceback (most recent call last):
File "/config/custom_components/aihome/__init__.py", line 526, in post
response = await HANDLER[platform].handleRequest(json.loads(data), refresh_token)
File "/config/custom_components/aihome/aligenie.py", line 169, in handleRequest
result = await self._controlDevice(name, payload)
File "/config/custom_components/aihome/aligenie.py", line 280, in _controlDevice
result = await self._hass.services.async_call(domain_list[i], service_list[i], data_list[i], True)
File "/usr/src/app/homeassistant/core.py", line 1150, in async_call
self._execute_service(handler, service_call))
concurrent.futures._base.CancelledError
2019-06-20 19:38:57 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 447, in start
await resp.prepare(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_response.py", line 353, in prepare
return await self._start(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_response.py", line 667, in _start
return await super()._start(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_response.py", line 410, in _start
await writer.write_headers(status_line, headers)
File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 112, in write_headers
self._write(buf)
File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 67, in _write
raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport
2019-06-20 19:39:02 WARNING (MainThread) [homeassistant.components.light] Updating homekit_controller light took longer than the scheduled update interval 0:00:30
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.