Okey, now it's done and this is how I did it.
I started by following Gravityz instructions that I got by mail but with some modifications.
Everything is done in PaperUI when nothing else is specified
1. Add MQTT 2.x binding under Add-ons
2. Create a MQTT broker thing
2a.
Add new Thing with the (
+) button
2b. Select
MQTT broker
2c. Give it a name, ip address and port (I'am using external MQTT mosquitto broker) I think configuration is self explained.
3. Create a MQTT binding thing
3a.
Add new Thing with the (
+) button
3b. Select
MQTT Binding
3c. Select
Add manually
3d. Select
Generic MQTT Thing
3e. Give it a name and ThingID like Domoticz and select your MQTT broker as bridge
4. Create a channel (One channel for every device you want to control)
4a. Select your created MQTT Binding Thing
4b. Select
Add Channel with the (
+) button
4c. Select
Number value
4d. Fill in the properties like this:
...
Channel Id: idx123 (Where 123 is your idx number. Like you did in that item file before with MQTT 1.x)
...
Label: Outdoor temperature (Name of your choice)
...
MQTT state topic: domotic/out
...
Incomming value transformations: REGEX:(.*\"idx\" : 117,.*)∩JSONPATH:$.svalue1
* If your device is a dimmer or a switch you choose that in step
4c.
* ... and set incomming value transformations to:
REGEX:(.*\"idx\" : 14,.*)∩JS:get_state.js
get_state.js
Code: Select all
(function(i){
var parsed = JSON.parse(i);
if (parsed.nvalue == 0)
{
return "OFF"
}
else if (parsed.nvalue == 1)
{
return "ON"
}
else if (parsed.nvalue == 2)
{
return parsed.svalue1
}
})(input);
5. We will create a roule like in the MQTT 1.x example erlier in this thread. And to get that working we need a controllable devices group
5a.
Add new Item with (+) button
5b. Fill in the properties like this:
...
Name: Controllable devices
...
Label: gControl (This must be same as in that rule file)
...
Type: Group
...
Base type: None
default.rule
Code: Select all
rule "Send MQTT message on Light command"
when
Member of gControl received command
then
var idxStartPos = triggeringItem.name.indexOf("idx") + 3
var idxStopPos = triggeringItem.name.length()
var myString = ""
if (receivedCommand.toString() == "ON" || receivedCommand.toString() == "OFF")
{
var cmd = receivedCommand.toString().toLowerCase.toFirstUpper()
myString = '{\"command\": \"switchlight\", \"idx\": ' + triggeringItem.name.substring(idxStartPos,idxStopPos) + ', \"switchcmd\": \"' + cmd + '\"}'
}
else
{
myString = '{\"command\": \"switchlight\", \"idx\": ' + triggeringItem.name.substring(idxStartPos,idxStopPos) + ', \"switchcmd\": \"Set Level\", \"level\": ' + receivedCommand.toString() + '}'
}
val actions = getActions("mqtt","mqtt:broker:290eaf06")
actions.publishMQTT("domoticz/in", myString)
end
6. If you are adding a temperature sensor they have to have a termostat group to get it working with Google Assistant
6a.
Add new Item with (
+) button
6b. Fill in the properties like this:
...
Name: Outdoor (Give it a name of your choice. This is what you will see in google home)
...
Label: gOutdoor_Termostat (Give your group a label of your choice)
...
Type: Group
...
Base type: None
7. Create items (If you migrate from MQTT 1.x to 2.x I guess you already have them but I explain it anyhow)
7a.
Add new Item with (
+) button
7b. Fill in the properties like this:
...
Name: Outdoor temperature (Give it a name of your choice)
...
Label: idx123 (Where 123 is your idx number. Like you did in that item file before with MQTT 1.x)
...
Type: Number (Number if it is a temp sensor, switch if it is a switch and dimmer if it is a dimmer

...
Parent groups: gOutdoor_Termostat (If it is a temperature sensor it have to have a termostat group for each one of them. If it is a Controllable device add that groupname you added above like gControl)
8. Let's connect our incomming data things with our devices.
8a. Under Things, your created Domoticz Thing and all your channels you can link to corresponding item.
8b. Select (+) button to add that link and choose corresponding item.
9. To get everything running in google home, we have to add a tags like in that old .items-file
9a. Install
REST Documentation User interface if you already have it installed
9b. Go in to that
Rest API interface from openhab start page
9c. Under items choose
GET /items and press
Try it out!
9d. Select and
copy the
Responding Body and
paste to notepad
9c. On every temperature sensor item you add the tag
"CurrentTemperature"
9c. On every termostat group item you add the tag
"Thermostat"
9c. On every light item you add the tag
"Lighting"
9c. On every outlet switch item you add the tag
"Switchable"
9d.
Before you do next step. Be sure to have a backup of your items in case of.
9e. Now select all text notepad and
paste into
PUT /items and press
Try it out!
10. Tell your google home to
update my devices
Notice: It's lot of work but you can take a shortcut if you know what you are doing by using Rest API to add all items and things instead of using the PaperUI. Maybe it's possible to migrate items from the .items-file to the new builtin storage by using that Rest API. I have not tried it but maybe you can get your items, copy the body, delete them and paste and add them back like above.
I read somewhere that you can't use PaperUI in Simple mode if you want to add links and items. You find that setting under Configuration --> System --> Item Linking