Alexicz - FREE Domoticz to Alexa Integration

Alexa, Google Home and Siri

Moderator: leecollings

Post Reply
Damsee
Posts: 58
Joined: Thursday 20 April 2017 1:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Alexicz - FREE Domoticz to Alexa Integration

Post by Damsee »

Hi all,

Here is another way to integrate Domoticz within Alexa (Amazon Echo) : Implementing your own skill for free.
Why did we start that skill ?
- HA-Bridge can not control all Domoticz features as it emulates HUE bridge (it's not possible to get temp statut and many others)
- Controlicz : A very nice way to integrate Domoticz within Alexa as this is using a native skill but the owner changed the access policy and Controlicz is not free anymore (no debate here as we understand it costs some HW/SW to develop/maintain that skill)
- We therefore wanted to start a skill to manage all Domoticz devices within Alexa (for free)

Credits :
- Madgeni : the owner/manager of Controlicz who first started to develop the idea of a skill. Thanks to Nick, we manage to get the Amazon philosophy for Smart Home Skill
- Rimram : a french user who developed the Python code of Alexicz "own" smart home skill and had some tests (based on his devices)
- Damsee : /me, another french user who wrote the documentation and had some tests (based on my own devices)

Based on Domoticz wiki (thanks to Prijt) :
By making your own Alexa Domoticz Smart Home skill, you can control your Domoticz devices without the need for extra hardware.
You must have or create an Amazon Developer Account and an Amazon Web Service account to host the Alexa lambda. The task to build your own skill looks a bit daunting at first, but if you follow the excellent HowTo, written by a fellow Domotic user to the letter, you will be up and running in no time. The HowTo also describes how you can get the needed Amazon accounts and can be found on GitHub.
As with all Alexa Smarthome skills (and with Controlicz) you will need to open/forward a port in your router. But once implemented you can control your devices not only by On/Off, but also dimming, change light colors, get the status (Temperature etc)

You can find full the documentation here :
https://github.com/rimram31/dz_smarthom ... zskill.pdf

All needed materials are here (code for the skill and lambda function) :
(https://github.com/rimram31/dz_smarthome/

Hope that helps.
Feel free for your comments and requested features, we'll try our best to improve the code and skill.


For debug purposes, please include the output of the following commands (as we required the Device Type) :
- http(s)://yourDomoticz/json.htm?type=devices&rid=nnn
- http(s)://yourDomoticz/json.htm?type=devices&used=true

Please note that the skill can only works with Alexa interfaces as described in the following tab :
Sans titre.png
Sans titre.png (35.02 KiB) Viewed 21781 times
It's therefore not possible to get power consumption of any kind as Alexa does not support this functionality yet.
RPI3 Raspbian Buster + Domoticz v2020.1 stable + RFXtrx433E + Z-Stick Gen5 + Amazon Echo (alexicz)
x5 THGN810 / x5 ZMNHJD1 / x2 Flood sensor FGFS101 / x1 Smoke sensor FGSD002
x1 ZMNHAD1 / x2 FGS213 / x3 Wallplug FGWPE/F / NodOn Soft remote CRC-3-6-0
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by EdddieN »

Interesting and following!

The only thing is I'm not to keen to open ports on my router.
I had been in the past involved on other Alexa skills projects and I guess what we need for avoiding port forwarding is a cloud MQTT server or similar?

I had a look at DZ MQTT but didn't find a easy way to separate users. I would be interested in exploring this idea a bit more if anyone is interested?
11101101 - www.machinon.com
trueblueswede
Posts: 4
Joined: Saturday 01 December 2018 18:13
Target OS: Windows
Domoticz version:
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by trueblueswede »

Hi,

I have followed the guide and my lambda function works and when testing it, it produces response JSON containing all my domoticz devices.
I also can add my skill and enable it but nothing happens when i do discovery. It seems that my lambda function never gets called.

Any idea where i should start troubleshooting?
satanasinc
Posts: 41
Joined: Monday 19 October 2015 12:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Spain
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by satanasinc »

Hola!

It works great! Thank you for for your hard work and for share it. Good work.

Easy and fast.

This post should be in the wiki, moderators please add it.

Thanx again and greetings from Spain.
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Alexicz - FREE Domoticz to Alexa Integration

Post by mvzut »

Wow, this actually works! The procedure involves a lot of steps, and an error is quickly made. But the guide was so clear that it worked immediately, amazing piece of work ! Thanks for the effort!

P.S. 1:
Since you asked for feedback and ideas, it would be nice if the skill could:
- Recognize door/window contacts as contacts instead of switches
- Read out the status of switches (and contacts)
- Read out humidity levels next to temperatures
Is this something that may eventually be added?

P.S. 2:
Looking at the code, it seems possible to define names for the levels of a selector switch using "Alexa_extra:" in the Domoticz device description. I don't think this feature is documented anywhere, correct?
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
Damsee
Posts: 58
Joined: Thursday 20 April 2017 1:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Damsee »

Good to hear you like it :D

@satanasinc : information is already in the wiki => https://www.domoticz.com/wiki/Amazon_Echo_(Alexa) :)

@trueblueswede : It should work as it's OK for others. Could you check every step of the documentation ?
Somes clues :
- As discovery is OK with your lambda function, could you try to get temp information of turn on a light (chapter 9.1 testing via Lambda) to ensure that Lambda is working and your DZ is fully available
- If that's OK, the issue is more on the Skill configuration and you should therefore check all the skill configuration settings

@mvzut :
- For contacts, could you please give us the DZ type so we can change the code ? (output of the following http(s)://yourDomoticz/json.htm?type=devices&rid=nnn where nnn is the device ID of your contact device). If we can set those devices as contacts within Alexa, we should therefore be able to query the status (answering your 2nd point for reading the status),

- Reading humidity levels ; that feature does not seem yet supported by Amazon... just tell us if we're wrong

- Defining names for the levels of a selector switch using "Alexa_extra:" is not documented you're right. It's still under development as it's not fully supported by Amazon. The current test is to match some levels from selector switchs to match the Alexa.ThermostatController Interface and defined levels (OFF/HEAT/COOL/AUTO). It means that Alexa would only recognize that levels and we had to match DZ selector switch level (WINTER / SUMMER for example) to Alexa ones (AUTO / OFF for examples) which is not the expected feature for Selector switchs from DZ...
RPI3 Raspbian Buster + Domoticz v2020.1 stable + RFXtrx433E + Z-Stick Gen5 + Amazon Echo (alexicz)
x5 THGN810 / x5 ZMNHJD1 / x2 Flood sensor FGFS101 / x1 Smoke sensor FGSD002
x1 ZMNHAD1 / x2 FGS213 / x3 Wallplug FGWPE/F / NodOn Soft remote CRC-3-6-0
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Alexicz - FREE Domoticz to Alexa Integration

Post by mvzut »

Damsee wrote: Friday 07 December 2018 10:47@mvzut :
- For contacts, could you please give us the DZ type so we can change the code ? (output of the following http(s)://yourDomoticz/json.htm?type=devices&rid=nnn where nnn is the device ID of your contact device). If we can set those devices as contacts within Alexa, we should therefore be able to query the status (answering your 2nd point for reading the status),
Here is the output of of the json command for one of my door contacts:

Code: Select all

{
   "ActTime" : 1544184256,
   "AstrTwilightEnd" : "18:27",
   "AstrTwilightStart" : "06:26",
   "CivTwilightEnd" : "17:00",
   "CivTwilightStart" : "07:53",
   "DayLength" : "07:44",
   "NautTwilightEnd" : "17:45",
   "NautTwilightStart" : "07:08",
   "ServerTime" : "2018-12-07 13:04:16",
   "SunAtSouth" : "12:05",
   "Sunrise" : "08:34",
   "Sunset" : "16:19",
   "app_version" : "4.10253",
   "result" : [
      {
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 0,
         "Data" : "Closed",
         "Description" : "Alexa_Name:Front door",
         "DimmerType" : "none",
         "Favorite" : 0,
         "HardwareID" : 11,
         "HardwareName" : "Aeon Z-Stick Gen5",
         "HardwareType" : "OpenZWave USB",
         "HardwareTypeVal" : 21,
         "HaveDimmer" : true,
         "HaveGroupCmd" : true,
         "HaveTimeout" : false,
         "ID" : "00000300",
         "Image" : "Light",
         "IsSubDevice" : false,
         "LastUpdate" : "2018-12-07 12:19:13",
         "Level" : 0,
         "LevelInt" : 0,
         "MaxDimLevel" : 100,
         "Name" : "Voordeur",
         "Notifications" : "false",
         "PlanID" : "3",
         "PlanIDs" : [ 3, 9 ],
         "Protected" : false,
         "ShowNotifications" : true,
         "SignalLevel" : "-",
         "Status" : "Closed",
         "StrParam1" : "",
         "StrParam2" : "",
         "SubType" : "Switch",
         "SwitchType" : "Contact",
         "SwitchTypeVal" : 2,
         "Timers" : "false",
         "Type" : "Light/Switch",
         "TypeImg" : "contact",
         "Unit" : 1,
         "Used" : 1,
         "UsedByCamera" : false,
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "149"
      }
   ],
   "status" : "OK",
   "title" : "Devices"
}
By the way, how do I actually check the status of a light/switch/contact? If I say "Alexa, what's the status of my front light?" it will respond "Sorry, front light doesn't support that". Equally for "state" instead of "status", and also if I ask " Is my front light on?"
Last edited by mvzut on Friday 07 December 2018 13:11, edited 1 time in total.
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
satanasinc
Posts: 41
Joined: Monday 19 October 2015 12:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Spain
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by satanasinc »

Damsee wrote: Friday 07 December 2018 10:47 Good to hear you like it :D

@satanasinc : information is already in the wiki => https://www.domoticz.com/wiki/Amazon_Echo_(Alexa) :)
Hi.

Sorry.


Greetings from Spain
trueblueswede
Posts: 4
Joined: Saturday 01 December 2018 18:13
Target OS: Windows
Domoticz version:
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by trueblueswede »

@Damsee: Thank you for your input and i´m very excited to get this to work.
I have followed the guide three times now but i cannot get the skill to discover my devices.
The lambda function works perfect, i can turn on the light and do a discovery.
I have an Echo Dot Gen 3 device that works fine with my Denon Heos skill for example.
Is there any way to see where it fails because if i look at the activity monitor in the lambda console i cannot see any activity at all and i suspect that my skill does not even get called when i´m doing a discovery.

Here is my configuration. I have validated all id to be the correct ones.

I´m grateful for any ideas.

https://imgur.com/a/MCrgvYk
Damsee
Posts: 58
Joined: Thursday 20 April 2017 1:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Damsee »

@satanasinc : no problem ;)

@trueblueswede : I guess your Lambda function is OK if you can turn on a light.
Could you check the logs within "Cloudwatch" through AWS ? You will be therefore able to check all lamdba activity and logs and we might try to get other status when you try to discover your devices.
GOTO AWS Management Console (once logged in aws.amazon.com) and select "CloudWatch" under "Management & Governance"
Click on LOGS on the left menu and select the Alexicz function to see the activity/logs.
Hope that helps.

@mvzut :
>> Will look for Contact...
>> Status for light ; that feature is not supported by Amazon / Alexa. You can check the Amazon Light interface which supports only the following commands :
- Turn a light on or off
- Set the power level of an endpoint
- Change the brightness of a light by percentage or to a specific value
- Change the color of a light
- Change the shade of white for a tunable light
whereas the Amazon Contact interface should support status command.
RPI3 Raspbian Buster + Domoticz v2020.1 stable + RFXtrx433E + Z-Stick Gen5 + Amazon Echo (alexicz)
x5 THGN810 / x5 ZMNHJD1 / x2 Flood sensor FGFS101 / x1 Smoke sensor FGSD002
x1 ZMNHAD1 / x2 FGS213 / x3 Wallplug FGWPE/F / NodOn Soft remote CRC-3-6-0
trueblueswede
Posts: 4
Joined: Saturday 01 December 2018 18:13
Target OS: Windows
Domoticz version:
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by trueblueswede »

@Damsee: Thanks for your assistance. In the logs, i only see my test runs. nothing that matches the time that i tried Discovery.
It seems to me like the Discovery command is not passed to my Lambda function for some reason. Would be interesting to look at the skills log if possible.
trueblueswede
Posts: 4
Joined: Saturday 01 December 2018 18:13
Target OS: Windows
Domoticz version:
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by trueblueswede »

@Damsee: I got it to work now, Very nice! In case someone runs into the same problem as I did here is what resolved my issues.
For some reason, it did not work to set the skill Language to EN(UK) and host the function in Ireland.
I exported the function and deployed it to Us(Virginia) and created a new skill with Language EN(Us) and voila it started to work.
Damsee
Posts: 58
Joined: Thursday 20 April 2017 1:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Damsee »

Good to see you manage to get it work :D
- the issue with the region versus locale (language) seems weird... is your Amazon account (when you linked your account during skill activation) is located in the US ?
- I have no logs for the skill since each user has its own logs :
> logs from your Domoticz (when your lambda function is querying/doing someting in DZ)
> logs from your lambda function available from CloudWatch through your AWS account

Regarding the "Contact", i got some documentation here :
https://developer.amazon.com/docs/devic ... faces.html
and the only supported language/locale for the Alexa.ContactSensor Interface is now : EN-US...
Looking at the same documentation, it seems that Amazon is now supporting "DZ Selector Switch" with the "Alexa.ModeController" but it's also restricted to EN-US locale.

Well... we have to work a little bit on the code... and trueblueswede would be happy since he changed its locale to EN-US ^^
RPI3 Raspbian Buster + Domoticz v2020.1 stable + RFXtrx433E + Z-Stick Gen5 + Amazon Echo (alexicz)
x5 THGN810 / x5 ZMNHJD1 / x2 Flood sensor FGFS101 / x1 Smoke sensor FGSD002
x1 ZMNHAD1 / x2 FGS213 / x3 Wallplug FGWPE/F / NodOn Soft remote CRC-3-6-0
rimram31
Posts: 26
Joined: Sunday 04 October 2015 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by rimram31 »

Thanks first to Damsee to relay this here (he his the documentation author of the skill too ...)

I've first wrote this skill in order to learn how Alexa skills work and trying to "make something working" (for me!). I've find an efficient path understanding madgeni code and being inspired by Home Assistant Alexa source code (https://github.com/home-assistant/home- ... rt_home.py)
EdddieN wrote: Monday 03 December 2018 18:33 ...The only thing is I'm not to keen to open ports on my router.
...
I had a look at DZ MQTT but didn't find a easy way to separate users. I would be interested in exploring this idea a bit more if anyone is interested?
I've think in all directions this skill architecture ... but face some difficulties/choices.

I've think about an MQTT implementation but this require a server side and/or some privacy garanties on the server side, the current solution is serveless and so, using the free AWS offer, remains free. Not trivial to find something else working for free.

Alternatively Home Asistant use some websocket, server initiated solution, another solution which will require too some hosted, not free, components ... (and I'm not a websocket expert!)

Having some hosted components and a registered skill is another choice, discussed with Damsee, but this require hosted components and also additional work (user registration, settings, skills registration ...)... The community is free to re use the code and documention provided :-)
mvzut wrote: Thursday 06 December 2018 22:15 ...
- Recognize door/window contacts as contacts instead of switches
- Read out the status of switches (and contacts)
- Read out humidity levels next to temperatures
Is this something that may eventually be added?
...
Thanks for your feedback. I will try to work on contact devices, doesn't seems to be too difficult (but Alexa API have evolved ...). As explained the skill reuse HA code and I've seen such devices are now implemented (https://github.com/home-assistant/home- ... me.py#L607)

Switches status (powerstate, lockstate ...) are returned by the skill, but perhaps I've miss something, I've not find a way, a "sentence" to be able to get the report state with Alexa. If someone has an idea.

Asking for improvements, you need to understand that an Alexa skill translate device features in "Alexa API" capabilities, we cannot make Alexa work in dz way, but try to make dz devices work in "Alexa way" (API)
nono212
Posts: 39
Joined: Sunday 18 December 2016 13:47
Target OS: Linux
Domoticz version: 3.6179
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by nono212 »

Thanks for the great work
I would like to know if this skill man handle the broadlink remote ?
It will allow to change channel ...
The broadlink skill is not available in French... but I prefer anyway to habit integrated in domoticz
Do you think it is possible ?
Damsee
Posts: 58
Joined: Thursday 20 April 2017 1:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Damsee »

Hi nono212,

It would be possible if your broadlink remote is defined within Domoticz devices.
Could you therefore give us the output of the following command for each DZ devices : http(s)://yourDomoticz/json.htm?type=devices&rid=nnn so we could match the Alexa API ?
RPI3 Raspbian Buster + Domoticz v2020.1 stable + RFXtrx433E + Z-Stick Gen5 + Amazon Echo (alexicz)
x5 THGN810 / x5 ZMNHJD1 / x2 Flood sensor FGFS101 / x1 Smoke sensor FGSD002
x1 ZMNHAD1 / x2 FGS213 / x3 Wallplug FGWPE/F / NodOn Soft remote CRC-3-6-0
rimram31
Posts: 26
Joined: Sunday 04 October 2015 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by rimram31 »

nono212 wrote: Sunday 09 December 2018 13:02 ...
I would like to know if this skill man handle the broadlink remote ?
It will allow to change channel ...
You're asking for some "multimedia" interface, Smart Home Alexa skills handle such device, called Entertainment
Devices https://developer.amazon.com/fr/docs/sm ... vices.html but not "natively" domoticz.

Alexicz skill purpose is to handle "standard" domoticz devices like switch, lights, sensors ... Perhaps you can have a look at Home Assistant ? It seems it handle such devices (but as I know Alexa skill is not free).
hayman
Posts: 66
Joined: Tuesday 15 March 2016 18:08
Target OS: NAS (Synology & others)
Domoticz version: 3.8153
Location: Nerthland
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by hayman »

Wow thanks for this I'll give it a try.....
Damsee
Posts: 58
Joined: Thursday 20 April 2017 1:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Damsee »

Damsee wrote: Saturday 08 December 2018 15:53 Regarding the "Contact", i got some documentation here :
https://developer.amazon.com/docs/devic ... faces.html
and the only supported language/locale for the Alexa.ContactSensor Interface is now : EN-US...
Looking at the same documentation, it seems that Amazon is now supporting "DZ Selector Switch" with the "Alexa.ModeController" but it's also restricted to EN-US locale.

Well... we have to work a little bit on the code... and trueblueswede would be happy since he changed its locale to EN-US ^^
Dear all,

We manage to change the code of the skill which is available on GIT : https://github.com/rimram31/dz_smarthome for the CONTACT_SENSOR.
As we do not have any contact devices, we didn't test the new functionality but feel free to give your feedbacks in the forum.

Enjoy :D
RPI3 Raspbian Buster + Domoticz v2020.1 stable + RFXtrx433E + Z-Stick Gen5 + Amazon Echo (alexicz)
x5 THGN810 / x5 ZMNHJD1 / x2 Flood sensor FGFS101 / x1 Smoke sensor FGSD002
x1 ZMNHAD1 / x2 FGS213 / x3 Wallplug FGWPE/F / NodOn Soft remote CRC-3-6-0
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by mvzut »

Alexicz (Alexa) sees my door/window contacts as contact sensors now, great!
However, I still can't ask "What the status of my front door?" (answer: "Front door doesn't support that"), or "Is my front door open?" (answer: "Hmmm... something is wrong with the front door, and I'm not sure if it's open"). Should something like that be supported at all?

Anyway, at least I can use them to start routines now, nice!
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests