Homematic
这Homematicintegration provides bi-directional communication with your CCU/Homegear. It uses an XML-RPC connection to set values on devices and subscribes to receive events the devices and the CCU emit. If you are using Homegear with pairedIntertechno设备,,,,uni-directional communication is possible as well.
这re is currently support for the following device types within Home Assistant:
- 二进制传感器
- Climate
- 覆盖
- 光
- 锁
- 通知
- 传感器
- 转变
设备支持可用于大多数有线和无线设备以及许多IP设备。如果您的设置具有混合协议,则必须配置其他界面s使用适当的端口。默认值是使用端口2001,即无线设备。有线设备通常可以通过端口2000和IP设备通过端口2010来获得。虚拟恒温程序CCU提供使用端口9292和要求您设置小路
设置为/groups
。当在CCU3上使用SSL时,默认情况下,与固定4相同的端口可用。因此,2001年成为42001,2010变为42010等。
Since CCU Version 3, the internal firewalls are enabled by default. You have to grant full access for theXML-RPC API
或在CCU的安全设置内指定家庭助理实例的IP地址并允许列表。必威是什么
如果您想查看是否支持特定设备,请前往Pyhomematicrepository and browse through the source code. A dictionary with the device identifiers (e.g., HM-Sec-SC-2) can be found within the relevant modules near the bottom. If your device is not supported, feel free to contribute.
我们会自动检测我们当前支持的所有设备,并尝试生成有用的名称。如果您启用了名称解析,我们将尝试通过JSON-RPC或您可能已安装在CCU上的XML-API从Metadata(Homegear)获取名称。由于这可能会失败,默认情况下将禁用。您可以使用家庭助理的手动重命名创建的实体必威是什么定制特征。自制的整合也得到了实体注册表,这使您可以直接在家庭助理UI中更改友好名称和实体ID。必威是什么
配置
要设置组件,请在您的configuration.yaml
文件:
自欺欺人:界面s:无线的:主持人:127.0.0.1
配置变量(全局):
配置变量(接口):
配置变量
CCU/HomeGear XML-RPC服务器的端口。无线:2001,有线:2000,IP:2010,恒温器:9292。在CCU3上启用SSL通常会在端口上备4个4。例如,2001将启用SSL变为42001。
Port of CCU JSON-RPC Server. The default is 80, but it may be different when running CCU virtually via Docker or with enabled SSL.
通过JSON-RPC获取名称时,您需要向CCU指定带有访客的用户。Admin-access is required if you work with variables on the CCU.
配置variables (host):
带有多个协议的示例配置,设置了一些其他选项
自欺欺人:界面s:rf:主持人:127.0.0.1分辨率:“JSON“用户名:“Admin"密码:“秘密”wired:主持人:127.0.0.1港口:2000分辨率:“JSON“用户名:“Admin"密码:“秘密”IP:主持人:127.0.0.1港口:2010组:主持人:127.0.0.1港口:9292分辨率:“JSON“用户名:“Admin"密码:“秘密”小路:/groups主持人:ccu2:主持人:127.0.0.1港口:2001用户名:“Admin"密码:“秘密”
分辨率选项
We use three approaches to fetch the names of devices. Each assumes you have properly named your devices in your existing Homematic setup. As a general advice: Use ASCII for your devices names. Home Assistant won’t include non-ASCII characters in entity-names.
JSON
:CCU允许通过JSON-RPC获取配对设备的详细信息。为此,您需要在组件配置中添加有效的凭据。来宾访问足以查询设备名称。XML
:If you use a CCU, there is an add-on called the “XML-API”. With it installed, you are able to fetch all kinds of information from you CCU using XML-RPC. We can leverage this and fetch the names of devices set within the CCU. We don’t support authentication with this method. TheJSON
方法应该优先XML
。对XML-API的支持仅适用于向下兼容性,并且可以在以后的版本中被禁用。元数据
:HomeGear通过内部具有元数据设备提供设备名称。使用HM-CFG-LAN接口时,通常使用配置软件(默认情况下是桌面上的快捷方式)来配置和配置设备。如果您配对设备,则会看到它们在表中列出。最左边的列(名称)预先填充默认名称。您可以单击此类名称并输入您喜欢的任何内容。
解决名称可能需要一些时间。因此,当您启动家庭助理时,您一开始就必威是什么不会看到设备。对于具有20多个设备的设置,最多可能需要一分钟,直到所有设备显示在UI中。
多个主机
为了允许并行与多个主机或不同协议(无线,有线和IP)进行通信,将建立多个连接,每个连接到已配置的目标。您为主机选择的名称必须是独特的,并且仅限于ASCII字母。使用多个主机的缺点,服务(下文解释)可能无法按预期工作。只能将一个连接用于服务,该连接限制了服务可以使用的设备/变量可用于主机的范围/协议。确实如此not影响家庭助理的实体。必威是什么他们都使用自己的联系并按预期工作。
读取实体的属性
除了其状态外,大多数设备都具有诸如电池状态或阀门位置之类的其他属性。这些可以使用自动化中的模板,甚至可以使用其自己的实体访问这些模板传感器component. Here’s an example of a template sensor that exposes the valve position of a thermostat.
模板:-传感器:-name:“卧室valve"状态:“{{state_attr('climate.leq123456','等级')}}””
变量
可以读取和设置您在CCU/HomeGear上设置的系统变量的值。设置值的支持类型是浮动和bool变量。使用CCU,需要具有管理员的用户。变量的状态可通过轮毂实体的属性获得(例如,homematic.ccu2
)。使用模板(如上所述)使您的变量可用于自动化或作为实体。变量的值以30秒的间隔从CCU/Homegear进行了轮询。设置变量的值立即发生并直接推动。
事件
When Homematic devices change their state or some other internal value, the CCU/Homegear sends event messages to Home Assistant. These events are automatically parsed and the entities in Home Assistant are updated. However, you can also manually use these events to trigger automations. Two event-types are available:
homematic.keypress
:For devices with buttons, see information below自欺欺人
:For impulse sensors
带有按钮的设备
带有按钮(例如HM-SEN-MDIR-WM55,遥控器)的设备在UI中可能不完全可见。这是旨在的,因为按钮在这里没有任何值,而他们所做的只是触发事件。例如:HM-SEN-MDIR-WM55运动检测器将显示为2个实体。运动传感器和亮度传感器。最重要的是,我们有4个事件的2集(每次按钮一组):press_short,press_long,press_cont,press_long_release。请注意,有些设备无法提供所有这些事件。但总的来说:如果可以按下它,通常至少具有press_short。
Here’s an example of how to use these events for automations:
自动化:扳机:平台:事件事件_type:homematic.keypressevent_data:name:“Kitchen转变”渠道:1param:press_short行动:服务:switch.turn_ontarget:ENTITY_ID:switch.kitchen_abbience
通道参数等于您要配置自动化的按钮的通道。您可以查看用于配对设备的UI中的可用频道。名称取决于您是否选择解析名称。如果没有,它将是设备ID(例如LEQ1234657)。如果您选择解析名称(这是成功的),那将是您在CCU或元数据中设置的名称(例如“厨房开关”)。
You can test whether your button works within Home Assistant if you look at the terminal output. When pressing a button, lines similar to those should appear:
2018-01-27 11:51:32信息((Thread-12)[pyhomematic.devicetypes.generic] hmgeneric.event:地址=MEQ1234567:6,界面_id=homeassistant-CCU2,key=press_short,价值=True 2018-01-27 11:51:32信息((MainThread)[HOMEASSISTANT.CORE]巴士:处理<事件homematic.keypress [l]:param=press_short,name=your_nice_name,渠道=6> 2018-01-27 11:51:32信息((Thread-12)[pyhomematic.devicetypes.generic] hmgeneric.event:地址=MEQ1234567:6,界面_id=homeassistant-CCU2,key=install_test,价值=真的
It may happen that “your_nice_name” is not resolved correctly; the according message (#2 in the above example) will be missing. This might be due to secure communication between your HM interface and the HM device. You can change the communication from “secure” to “standard” within your HM-interface to solve that issue (in “Einstellungen” - “Geräte” find your device and change “Übertragungsmodus” from secure to standard) - not recommended for devices that should have secure communication.
HOMEMATIC.KEYPRESS事件
得到homematic.keypress
对于某些自制的IP设备,例如WRC2 / WRC6(墙开关)或SPDR(通道传感器)或KRC4(键环遥控器),您必须临时为CCU中的每个通道创建一个空程序:
- In the menu of your CCU’s admin panel go to
Programs and connections
>程序和CCU连接
- 去
新的
在页脚菜单中 - 单击下面的加号图标
条件:如果...
然后按按钮设备选择
- 选择您需要的设备之一(WRC2 / WRC6的1-2 / 1-6,SPDR的2-3)
- 选择简短或长键按
- 保存程序
好的
button - 按照步骤5中的配置来触发程序。您的设备可能会通过绿色LED或类似方式指示成功。当您选择设备时
Status and control
>设备
在CCU上,上一次更改
字段不应再为空 - When your channel is working now, you can edit it to select the other channels one by one
- 最后,您可以从CCU删除此程序
Services
- homematic.virtualkey:使用设备或虚拟密钥模拟CCU/HomeGear上的按键(或其他有效的操作)。
- homematic.reconnect:Reconnect to CCU/Homegear without restarting Home Assistant (useful when CCU has been restarted)
- homematic.set_variable_value:设置系统变量的值。
- homematic.set_device_value:手动控制设备(甚至没有支持的设备)。等效于XML-RPC的setValue方法。
- 自欺欺人。put_paramset:手动更改设备的参数(甚至没有支持的设备)。等效于XML-RPC的PutParamSet方法。
例子
Simulate a button being pressed:
。。。行动:服务:homematic.virtualkey数据:地址:“Bidcos-RF”渠道:1param:press_long
Open KeyMatic:
。。。行动:服务:homematic.virtualkey数据:地址:“LEQ1234567“渠道:1param:OPEN
将布尔变量设置为true:
。。。行动:服务:homematic.set_variable_valuetarget:ENTITY_ID:homematic.ccu2数据:name:“变量名”价值:真的
高级示例
如果您熟悉自制设备的内部设备,则可以在设备上手动设置值。如果目前尚无对设备的支持,或者仅实施了有限的功能,则可以作为解决方法。使用此服务使您可以直接访问主要连接的setValue方法。如果您有多个主机,则可以通过为代理参数提供与您选择的名称相等的值选择托管特定设备的一个。在上面的示例配置中rf
,,,,wired
和IP
将是有效的值。
手动打开开关演员:
。。。行动:服务:homematic.set_device_value数据:地址:“LEQ1234567“渠道:1param:状态价值:真的
在恒温器上手动设置温度:
。。。行动:服务:homematic.set_device_value数据:地址:“LEQ1234567“渠道:4param:set_temperature价值:23.0
手动在恒温器上设置主动轮廓:
。。。行动:服务:homematic.set_device_value数据:地址:“LEQ1234567“渠道:1param:Active_profile价值:1值类型:int
设置墙壁恒温器的一周计划:
。。。行动:服务:自欺欺人。put_paramset数据:界面:无线的地址:“LEQ1234567“paramset_key:掌握参数:Week_program_pointer:1
Set the week program of a wall thermostat with explicitrx_mode
(仅BIDCOS-RF):
。。。行动:服务:自欺欺人。put_paramset数据:界面:无线的地址:“LEQ1234567“paramset_key:掌握rx_mode:WAKEUP参数:Week_program_pointer:1
BIDCOS-RF设备具有put_paramset的可选参数,该参数定义了配置数据发送到设备的方式。
rx_mode
BURST
,,,,which is the default value, will wake up every device when submitting the configuration data and hence makes all devices use some battery. It is instant, i.e. the data is sent almost immediately.
rx_mode
WAKEUP
仅在设备提交更新的值向CCU提交的更新值之后,通常会每3分钟发生一次配置数据。它不会唤醒每个设备,从而节省设备电池。
手动在keymatic设备上设置锁定:
。。。行动:服务:锁target:ENTITY_ID:lock.leq1234567
手动设置在Keymatic设备上解锁:
。。。行动:服务:lock.unlocktarget:ENTITY_ID:lock.leq1234567
集成HMIP-DLD
当前Pyhomematic
执行。解决方法是在您的配置中定义模板锁:
锁:-平台:模板name:基础唯一身份:基础value_template:“{{是_state('sensor.lock_status','locked')}}””锁:服务:homematic.set_device_value数据:地址:“002A1BE9A792D2“渠道:1param:lock_target_level价值:0unlock:服务:homematic.set_device_value数据:地址:“002A1BE9A792D2“渠道:1param:lock_target_level价值:1
检测失去的连接
当丢失了与您的自制CCU或家庭饮料的连接时,家必威体育存款庭助理将停止从设备获得更新。必威是什么例如,在重新启动CCU之后可能会发生这种情况。由于通信协议的性质,这不能自动处理,因此您必须致电homematic.reconnect在这种情况下。这就是为什么通常是一个好主意,最好检查您的家庭集成是否仍适当更新,以检测连接损失。必威体育存款这可以通过自动化以几种方式完成:
- 如果您有一个传感器,您知道会经常更新(例如,室外温度传感器,电压传感器或光传感器),则可以设置一个辅助二进制传感器和这样的自动化:
模板:-binary_sensor:-name:“Homematic是发送updates"状态:> -{{(NOW() - states.sensor.office_voltage.last_changed).seconds <600}}}自动化:-别名:“Homematic重新连接”扳机:平台:状态ENTITY_ID:binary_sensor.homematic_is_sending_updatesto:“离开”行动:#重新连接,如果传感器在10分钟以上没有更新服务:homematic.reconnect
重要的部分是传感器时间
实体(来自time_date组件)。这将在传感器和每一分钟的每一个更改中更新二进制传感器。如果自制传感器不再发送任何更新,则传感器时间
将把二进制传感器设置为离开
最后一次传感器更新后10分钟。这将触发自动化。
如果您有CCU,则还可以在CCU上创建系统变量,该变量存储其最后一次重新启动时间。由于家庭助理必威是什么仍然可以从CCU刷新系统变量(即使在重新启动后),这是另一个可以致电的选项homematic.reconnect。即使此选项看起来可能比许多选项更可取,因为它不依赖传感器,但it is less fail-safethan checking for updates of a sensor. Since the variable on the CCU is only changed on boot, any problem that causes the connection between Home Assistant and the CCU to break but will not result in a reboot will not be detected (eg. in case of networking issues). This is how this can be done:
创建一个字符串变量v_last_rebooton the CCU
在CCU上创建一个新程序without any conditions,,,,which executes the followingHM-Script延迟30秒。该脚本需要在本节中实现
活动:然后
。varOBJ=dom。getObject((“v_last_reboot“);stringnow=系统。日期((“%d。%m。%y%h:%m:%s“);OBJ。状态((now);
这Homematic CCU will execute all active programs which meet their conditions (none in this case) on every reboot.
在家庭助理中设置模板传感器,其中包含系统变量的值:必威是什么
模板:-传感器:-name:“vlast重启”状态:“{{state_attr('homematic.ccu2','v_last_reboot')或者'01.01.197000:00:00'}}””图标:“MDI:时钟”
设置一个呼叫的自动化homematic.reconnectwhenever the sensor variable changes:
自动化:-别名:“HomematicCCU重启”扳机:平台:状态ENTITY_ID:传感器。V_LAST_REBOOT行动:服务:homematic.reconnect
通知
这自欺欺人
通知平台启用调用家庭设备。
要在安装中使用此通知平台,请添加以下内容configuration.yaml
文件:
配置
#示例Configuration.yaml条目通知:-name:my_hm平台:自欺欺人地址:“neqxxxxxxx”渠道:2param:“提交”价值:“1,,,,1,,,,108000,8"
用法
自欺欺人
是一个通知平台,可以通过调用通知服务来控制如下所述。
Only the数据
事件有效载荷的一部分已处理。该部分可以指定或覆盖为配置变量给出的值:
{“数据”:{“地址”:“ neqxxxxxxx”,,,,“渠道”:2,,,,“ param”:“提交”,,,,“价值”:“1,,,,1,,,,108000,8"}}
可以提供模板以计算值:
{“数据”:{“价值”:“ 1,1,108000 {%如果IS_STATE('Binary_sensor.oeqxxxxxxxxxxx_state','on')%},1 {%endif%} {%iS_STATE('binary_sensor.oeqxxxxxxxxxxxxxx_state'% 万一 %}”}}
您还可以使用组通知指定事件有效载荷(而不是指定通知本身的值):
通知:-name:my_hm平台:自欺欺人地址:neqxxxxxxx-name:group_hm平台:团体服务s:-服务:my_hm数据:数据:价值:“1,1,108000 {%如果IS_STATE('Binary_sensor.oeqxxxxxxx_state','在')%},1{%endif%} {%如果IS_STATE('Binary_sensor.oeqxxxxxxx_state','在')%},2 {%endif%}””警报:temperature:name:Temperature too highDone_message:温度正常ENTITY_ID:binary_sensor.temperature_too_highcan_acknowledge:真的notifiers:-group_hm
请注意,第一个数据
element belongs to the servicemy_hm
,而第二个属于事件有效载荷。