To add a device to OpenHAB, we need to configure fourĀ files:
- /configurations/openhab.cfg
- /configurations/items
- /configurations/sitemap
- /configurations/rules/
Under /configurations/openhab.cfg:
Turn on MQTT
################################### MQTT Transport ######################################### # mqtt:mymosquitto.url=tcp://localhost:1883 mqtt:mymosquitto.qos=0 mqtt:mymosquitto.retain=true mqtt:mymosquitto.async=true
Under /configurations/items/demo.items:
Number itm_garage_dist "Garage Dist [%.1f Inch]" (ALL) {mqtt="<[mymosquitto:4032:state:default]"} Contact itm_my_gar_door "Garage Door Status [MAP(en.map):%s]" <garage> (ALL)
Under /configurations/sitemap/demo.sitemap:
Frame label="Garage" { Text item=itm_my_gar_door label="Garage Door Status [%s]" }
Under /configurations/rules/:
rule "Convert Door" when Item itm_garage_dist received update then if(itm_garage_dist.state < 19) { itm_my_gar_door.state = OPEN } else { itm_my_gar_door.state = CLOSED } end
Leave a Reply
You must be logged in to post a comment.