Update:
- 2023-03-29 Updated the script to be compatible with helper library 5.0
The items/things file can be generated automatically when devices.yaml file is updated with the help of this rule:
require "personal"
require "personal/itemsgen"
rule "Autogen Items" do
watch OpenHAB::Core.config_folder / "misc" / "devices.yaml", for: :modified
run do |event|
logger.info("#{event.path} #{event.type}. Regenerating things/items file.")
yaml = YAML.load_file(event.path)
gen = OpenhabGenerator::Devices.new(yaml)
gen.template_dir = OpenHAB::Core.config_folder / "misc" / "templates"
output = gen.generate
File.write(OpenHAB::Core.config_folder / "things" / "z_generated.things", output["things"])
File.write(OpenHAB::Core.config_folder / "items" / "z_generated.items", output["items"])
end
end