Alexicz - FREE Domoticz to Alexa Integration

Alexa, Google Home and Siri

Moderator: leecollings

Skwi
Posts: 18
Joined: Thursday 10 May 2018 9:37
Target OS: Windows
Domoticz version:
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Skwi »

For the appliance, I found this terme in the pdf §9.1 : https://github.com/rimram31/dz_smarthom ... zskill.pdf
You're saying that "SwitchLight, TemperatureSensor, etc" are a compound of the v3 smart home from amazon, is there list somewhere?

Thanks for the log's link but it's empty. From the lambda function I can clic "show the logs in cloudwatch", it brings me to your page with an error saying the log group "/aws/lambda/alexicz" doesn't exist. I created this group but still empty.

Beside this, I got all the "metrics" with the number of error, duration etc, but no details on the errors.

Do I need to create a "stream log" or something else? (some binding missing?)
Skwi
Posts: 18
Joined: Thursday 10 May 2018 9:37
Target OS: Windows
Domoticz version:
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Skwi »

I still don't know how to print the logs, but I think I've found why it works randomly : firewall
Domoticz is installed on a synology nas. I configured the firewall on it to block all the traffic towards domoticz except from "france" (me) and "irlande" (aws).
If I remove irlande, it's 100% failure. It must be one of the IP aws is using from irlande which is not in the synology list of 'irlande'.
And of course, synology don't log what is rejected by the firewall
I canno't find the IP behind the countries in synology, but I've found all the ip ranges on aws : https://ip-ranges.amazonaws.com/ip-ranges.json

Irlande is on eu-west-1, so I filtered the json with : prefixes[?region=='eu-west-1']|[?service=='S3'].ip_prefix and tried the 3 ranges without success.
Here is the list of the "services", do you know which one is used by aws for the lambda functions? There is to much range for AMAZON and EC2 to try :/

"AMAZON",
"ROUTE53_HEALTHCHECKS",
"S3",
"DYNAMODB",
"EC2",
"CODEBUILD",
"GLOBALACCELERATOR",
"ROUTE53_HEALTHCHECKS_PUBLISHING",
"CLOUDFRONT",
"API_GATEWAY",
"CLOUD9",
"EC2_INSTANCE_CONNECT",
"WORKSPACES_GATEWAYS",
User avatar
philchillbill
Posts: 399
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by philchillbill »

Skwi wrote: Tuesday 12 May 2020 20:28 For the appliance, I found this terme in the pdf §9.1 : https://github.com/rimram31/dz_smarthom ... zskill.pdf
You're saying that "SwitchLight, TemperatureSensor, etc" are a compound of the v3 smart home from amazon, is there list somewhere?

Thanks for the log's link but it's empty. From the lambda function I can clic "show the logs in cloudwatch", it brings me to your page with an error saying the log group "/aws/lambda/alexicz" doesn't exist. I created this group but still empty.

Beside this, I got all the "metrics" with the number of error, duration etc, but no details on the errors.

Do I need to create a "stream log" or something else? (some binding missing?)
Ah, now I see where you got appliance from. applicandeId used to be the old name for endpointId which is what confused me, but in the PDF it's just a placeholder. Alexicz endpointIds are formed by adding the idx of the device in Domoticz to the class name of the category assigned during discovery. So e.g. a lamp with idx of 301 would be called SwitchLight-301 in Alexicz. To test that device in the console, you would use that specific endpointId instead of the Appliance-001 placeholder.

You really need to look at the JSON response from Domoticz in my post above and ask yourself how each device would walk through the discovery code in DomoticzHandler.py. I completely re-wrote the discovery code based on how I wanted things handled. That's the advantage of having the source code - it's no longer a black box so you can figure out its exact workings, plus you can tailor it to your needs.
Last edited by philchillbill on Wednesday 13 May 2020 9:39, edited 1 time in total.
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
User avatar
philchillbill
Posts: 399
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by philchillbill »

Skwi wrote: Tuesday 12 May 2020 10:29 Hi, I can now test from the lambda function. Si I could try from the aws to get the logs when the problem occurs.

Reading this thread I found that for a switch I must declare endpointID = "SwitchLight-idx"
In the pdf it's written we have to change the 'appliance-001' into "SwitchLight-Domoticz IDX", and I read it as "the idx of my switch light"
Is there a list of all the "appliances" (except in the DomoticzHandler.py)?
You would normally see that list in Cloudwatch logs in the Discovery response which would show the JSON returned to Alexa upon finishing discovery. They will be the "endpointId" parameters in the JSON.
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
User avatar
philchillbill
Posts: 399
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by philchillbill »

Skwi wrote: Tuesday 12 May 2020 20:28 Thanks for the log's link but it's empty. From the lambda function I can clic "show the logs in cloudwatch", it brings me to your page with an error saying the log group "/aws/lambda/alexicz" doesn't exist. I created this group but still empty.
Regarding the Cloudwatch logs, you need to have set up am IAM role giving permission for logging. See https://docs.aws.amazon.com/lambda/late ... -role.html
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
Skwi
Posts: 18
Joined: Thursday 10 May 2018 9:37
Target OS: Windows
Domoticz version:
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Skwi »

philchillbill wrote: Wednesday 13 May 2020 9:35
Skwi wrote: Tuesday 12 May 2020 10:29 Hi, I can now test from the lambda function. Si I could try from the aws to get the logs when the problem occurs.

Reading this thread I found that for a switch I must declare endpointID = "SwitchLight-idx"
In the pdf it's written we have to change the 'appliance-001' into "SwitchLight-Domoticz IDX", and I read it as "the idx of my switch light"
Is there a list of all the "appliances" (except in the DomoticzHandler.py)?
You would normally see that list in Cloudwatch logs in the Discovery response which would show the JSON returned to Alexa upon finishing discovery. They will be the "endpointId" parameters in the JSON.
I am not the one with the discovery issues, it was a previous post.

And big thank you for the logs, I followed the instructions you linked : https://docs.aws.amazon.com/lambda/late ... -role.html

I already had a role so I created added the permissions policies with no success. Then I created a new role (following Creating an execution role in the IAM console), then in the lambda function permission selected this new role (then save). And now I do have the logs <3
CloudWatch> CloudWatch Logs> Log groups>/aws/lambda/alexicz>2020/05/13/[$LATEST]01df8165006d4695ac3eb5e85e1314b5

But now that I know it is a firewall issue, I must find a way to know what ip range is missing in my rule (no logs on synology, and no ip in the aws logs :p)
User avatar
philchillbill
Posts: 399
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by philchillbill »

Take a look at https://ip-ranges.amazonaws.com/ip-ranges.json for a list of all the Amazon IPs in use at any time (it's in JSON format). And remember it updates daily. And then forget you ever thought about trying to whitelist AWS for your firewall :mrgreen:
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
Skwi
Posts: 18
Joined: Thursday 10 May 2018 9:37
Target OS: Windows
Domoticz version:
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Skwi »

I've already found this json, and yes it's hard (impossible?) to whitelist all that is needed. Until now it worked at 99%, but now it's more like 70%.
Viewing this map : https://aws.amazon.com/about-aws/global-infrastructure/
I added "Great-Britain" in the firewall, maybe if aws irlande is not available it's scaled to try the closest datastore?
Wait & see..

Edit:
On this site it's written Regional Edge Caches Frankfurt, Germany; London, England for europe
Don't know exactly what that means but maybe it's what I'm searching for : if Irelande is not available, it's executed on england or germany (?)
Romel
Posts: 15
Joined: Tuesday 06 August 2019 14:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Kromeriz / Czech
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Romel »

Hi, is here someone who can discover zigbee devices ?
I am running zigbee2mqtt, I added description of light :"Alexa_Name:computer", but Alexicz cant discover it. Other items was discovered fine.
User avatar
philchillbill
Posts: 399
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by philchillbill »

Romel wrote:Hi, is here someone who can discover zigbee devices ?
I am running zigbee2mqtt, I added description of light :"Alexa_Name:computer", but Alexicz cant discover it. Other items was discovered fine.
Look at http://192.168.x.y:8080/json.htm?type=devices&rid=aaa (where aaa is the idx of your zigbee light) in your browser. Now ask yourself how that json will be interpreted within DomoticzHandler. What class of endpoint will it fall under?
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
Romel
Posts: 15
Joined: Tuesday 06 August 2019 14:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Kromeriz / Czech
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Romel »

philchillbill wrote: Wednesday 27 May 2020 22:15
Romel wrote:Hi, is here someone who can discover zigbee devices ?
I am running zigbee2mqtt, I added description of light :"Alexa_Name:computer", but Alexicz cant discover it. Other items was discovered fine.
Look at http://192.168.x.y:8080/json.htm?type=devices&rid=aaa (where aaa is the idx of your zigbee light) in your browser. Now ask yourself how that json will be interpreted within DomoticzHandler. What class of endpoint will it fall under?
Hi plilchillbill and thank you for helping!
IDx of zigbee light is 38 and here is json output:

Code: Select all

{
	"ActTime" : 1590649772,
	"AstrTwilightEnd" : "23:51",
	"AstrTwilightStart" : "01:45",
	"CivTwilightEnd" : "21:25",
	"CivTwilightStart" : "04:11",
	"DayLength" : "15:52",
	"NautTwilightEnd" : "22:21",
	"NautTwilightStart" : "03:14",
	"ServerTime" : "2020-05-28 09:09:32",
	"SunAtSouth" : "12:48",
	"Sunrise" : "04:52",
	"Sunset" : "20:44",
	"app_version" : "2020.2",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"Color" : "{\"b\":0,\"cw\":0,\"g\":0,\"m\":2,\"r\":0,\"t\":127,\"ww\":0}",
			"CustomImage" : 0,
			"Data" : "Off",
			"Description" : "Alexa_Name:computer",
			"DimmerType" : "abs",
			"Favorite" : 0,
			"HardwareID" : 9,
			"HardwareName" : "Zigbee2mqttRaspberryPi",
			"HardwareType" : "Zigbee2MQTT",
			"HardwareTypeVal" : 94,
			"HaveDimmer" : true,
			"HaveGroupCmd" : false,
			"HaveTimeout" : false,
			"ID" : "0x680ae2fffe160741_light",
			"Image" : "Light",
			"IsSubDevice" : false,
			"LastUpdate" : "2020-05-27 23:07:04",
			"Level" : 1,
			"LevelInt" : 1,
			"MaxDimLevel" : 100,
			"Name" : "sw-pc-desk",
			"Notifications" : "false",
			"PlanID" : "7",
			"PlanIDs" : 
			[
				7
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"Status" : "Off",
			"StrParam1" : "",
			"StrParam2" : "",
			"SubType" : "WW",
			"SwitchType" : "Dimmer",
			"SwitchTypeVal" : 7,
			"Timers" : "false",
			"Type" : "Color Switch",
			"TypeImg" : "dimmer",
			"Unit" : 11,
			"Used" : 1,
			"UsedByCamera" : false,
			"XOffset" : "279",
			"YOffset" : "214",
			"idx" : "38"
		}
	],
	"status" : "OK",
	"title" : "Devices"
}
I suppose that it is dimmer class ? I dont know what do you expectly meaning class of endpoint.
Here is another device working well:

Code: Select all

{
	"ActTime" : 1590650020,
	"AstrTwilightEnd" : "23:51",
	"AstrTwilightStart" : "01:45",
	"CivTwilightEnd" : "21:25",
	"CivTwilightStart" : "04:11",
	"DayLength" : "15:52",
	"NautTwilightEnd" : "22:21",
	"NautTwilightStart" : "03:14",
	"ServerTime" : "2020-05-28 09:13:40",
	"SunAtSouth" : "12:48",
	"Sunrise" : "04:52",
	"Sunset" : "20:44",
	"app_version" : "2020.2",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"CustomImage" : 0,
			"Data" : "Off",
			"Description" : "Alexa_Name: dining light",
			"DimmerType" : "none",
			"Favorite" : 0,
			"HardwareID" : 3,
			"HardwareName" : "dummy",
			"HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
			"HardwareTypeVal" : 15,
			"HaveDimmer" : true,
			"HaveGroupCmd" : true,
			"HaveTimeout" : false,
			"ID" : "00014056",
			"Image" : "Light",
			"IsSubDevice" : false,
			"LastUpdate" : "2020-05-27 23:07:02",
			"Level" : 99,
			"LevelInt" : 99,
			"MaxDimLevel" : 100,
			"Name" : "sw-jidedlni-stul",
			"Notifications" : "false",
			"PlanID" : "7",
			"PlanIDs" : 
			[
				7
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"Status" : "Off",
			"StrParam1" : "",
			"StrParam2" : "",
			"SubType" : "Switch",
			"SwitchType" : "On/Off",
			"SwitchTypeVal" : 0,
			"Timers" : "false",
			"Type" : "Light/Switch",
			"TypeImg" : "lightbulb",
			"Unit" : 1,
			"Used" : 1,
			"UsedByCamera" : false,
			"XOffset" : "212",
			"YOffset" : "172",
			"idx" : "6"
		}
	],
	"status" : "OK",
	"title" : "Devices"
}
User avatar
philchillbill
Posts: 399
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by philchillbill »

It should be caught by

Code: Select all

if (devType.startswith('Lighting') or devType.startswith('Color Switch'))
and the

Code: Select all

if switchType == 'On/Off'
will be false so

Code: Select all

                    # Usual switch case
                    endpoint = SwitchLightAlexaEndpoint("SwitchLight-"+endpointId, friendlyName, description, manufacturerName)
                    endpoint.addDisplayCategories("LIGHT")
                    hasDimmer = deviceHasDimmer(device)
                    if (hasDimmer):
                        endpoint.addCapability(AlexaPercentageController(self, 'Alexa.PercentageController',[{'name': 'percentage'}]))
                        endpoint.addCapability(AlexaBrightnessController(self, 'Alexa.BrightnessController',[{'name': 'brightness'}]))              
                    subType = device['SubType']
                    if (subType.startswith("RGB")):
                        endpoint.addCapability(AlexaColorController(self, 'Alexa.ColorController'))              
                        endpoint.addCapability(AlexaColorTemperatureController(self, 'Alexa.ColorTemperatureController'))
meaning it is discoverable with the code in DomoticzHandler. Did you assign it a room ID?
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
Romel
Posts: 15
Joined: Tuesday 06 August 2019 14:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Kromeriz / Czech
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Romel »

philchillbill wrote: Thursday 28 May 2020 10:05 meaning it is discoverable with the code in DomoticzHandler. Did you assign it a room ID?
Yes I assigned it to room - it should be:

Code: Select all

"PlanID" : "7",
Another dimmer is working well:

Code: Select all

{
	"ActTime" : 1590654864,
	"AstrTwilightEnd" : "23:51",
	"AstrTwilightStart" : "01:45",
	"CivTwilightEnd" : "21:25",
	"CivTwilightStart" : "04:11",
	"DayLength" : "15:52",
	"NautTwilightEnd" : "22:21",
	"NautTwilightStart" : "03:14",
	"ServerTime" : "2020-05-28 10:34:24",
	"SunAtSouth" : "12:48",
	"Sunrise" : "04:52",
	"Sunset" : "20:44",
	"app_version" : "2020.2",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"Color" : "{\"b\":255,\"cw\":0,\"g\":255,\"m\":3,\"r\":255,\"t\":0,\"ww\":0}",
			"CustomImage" : 0,
			"Data" : "Off",
			"Description" : "Alexa_Name: kitchen",
			"DimmerType" : "abs",
			"Favorite" : 1,
			"HardwareID" : 3,
			"HardwareName" : "dummy",
			"HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
			"HardwareTypeVal" : 15,
			"HaveDimmer" : true,
			"HaveGroupCmd" : false,
			"HaveTimeout" : false,
			"ID" : "00082009",
			"Image" : "Light",
			"IsSubDevice" : false,
			"LastUpdate" : "2020-05-27 23:07:23",
			"Level" : 51,
			"LevelInt" : 51,
			"MaxDimLevel" : 100,
			"Name" : "ledky kuchyn\u011b",
			"Notifications" : "false",
			"PlanID" : "3",
			"PlanIDs" : 
			[
				3
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"Status" : "Off",
			"StrParam1" : "",
			"StrParam2" : "",
			"SubType" : "RGBW",
			"SwitchType" : "Dimmer",
			"SwitchTypeVal" : 7,
			"Timers" : "false",
			"Type" : "Color Switch",
			"TypeImg" : "dimmer",
			"Unit" : 1,
			"Used" : 1,
			"UsedByCamera" : false,
			"XOffset" : "121",
			"YOffset" : "237",
			"idx" : "9"
		}
	],
	"status" : "OK",
	"title" : "Devices"
}
Romel
Posts: 15
Joined: Tuesday 06 August 2019 14:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Kromeriz / Czech
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Romel »

new scene can be discovered. But no new light discovered... I dont know why :(
Output of Configure test events - discovery in console.aws.amazon.com dont show new light. Light assigned to room same as other light woking.
Last edited by Romel on Thursday 04 June 2020 6:56, edited 1 time in total.
User avatar
philchillbill
Posts: 399
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by philchillbill »

Romel wrote:new scene can be discovered. But no new light discovered... I dont know why :(
Output of Configure test events - discovery in console.aws.amason.com dont show new light. Light assigned to room same as other light woking.
Take a look on Cloudwatch Logs at the Discovery response to see if it’s in the JSON being returned to Amazon. Sometimes devices are there but your account does not “accept” them. Amazon bug.
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
DrMacabre
Posts: 74
Joined: Monday 26 December 2016 16:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: France
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by DrMacabre »

Hello,

Does anyone have an unresponsive skill since this morning ? Last night everything was fine and today, none of my devices are responding.
User avatar
philchillbill
Posts: 399
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by philchillbill »

DrMacabre wrote:Hello,

Does anyone have an unresponsive skill since this morning ? Last night everything was fine and today, none of my devices are responding.
No problems here. Did you check the cloud watch logs? Is your external Domoticz URL still valid?
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
DrMacabre
Posts: 74
Joined: Monday 26 December 2016 16:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: France
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by DrMacabre »

philchillbill wrote: Saturday 06 June 2020 14:08
DrMacabre wrote:Hello,

Does anyone have an unresponsive skill since this morning ? Last night everything was fine and today, none of my devices are responding.
No problems here. Did you check the cloud watch logs? Is your external Domoticz URL still valid?
When using test on the function it says task timed out after 3 seconds. The domain is accessible and domoticz as well. When trying to look at the log group, it says log group doesn’t exist.
DrMacabre
Posts: 74
Joined: Monday 26 December 2016 16:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: France
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by DrMacabre »

Nevermind, my domain is down for some unknown reason. 😪
Romel
Posts: 15
Joined: Tuesday 06 August 2019 14:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Kromeriz / Czech
Contact:

Re: Alexicz - FREE Domoticz to Alexa Integration

Post by Romel »

philchillbill wrote: Wednesday 03 June 2020 20:16
Romel wrote:new scene can be discovered. But no new light discovered... I dont know why :(
Output of Configure test events - discovery in console.aws.amason.com dont show new light. Light assigned to room same as other light woking.
Take a look on Cloudwatch Logs at the Discovery response to see if it’s in the JSON being returned to Amazon. Sometimes devices are there but your account does not “accept” them. Amazon bug.
Hi, problem SOLVED by setting devices under Domoticz user defined in configdz.json in lambda ... ufff :)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest