Page 2 of 17
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Wednesday 12 December 2018 10:21
by rimram31
mvzut wrote: ↑Tuesday 11 December 2018 22:48
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!
Nice to know.
Regarding the issue "... something is wrong ...", I've had the same answer developping the skill, V3 version require sometimes a "payload answer" more complete (context part). I will try to work on this as soon as I can.
Alexicz - FREE Domoticz to Alexa Integration
Posted: Wednesday 12 December 2018 11:19
by mvzut
Ok, thanks!
Another question: if I send you the Domoticz JSON output of a motion sensor, can you then also implement that in the code? Wouldn't it be nice if Alexa could alert me to movement in and/or around the house at night? (Although the WAF will largely depend on the reliability of the sensor
)
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Wednesday 12 December 2018 17:10
by joys
Hi, i have some problem. I have not any echo device but only Alexa app on my mobile. so I try to execute a discover from Lambda function on AWS but I have this error.
'directive': KeyError
Traceback (most recent call last):
File "/var/task/lambda.py", line 49, in event_handler
response = AlexaSmartHome.handle_message(dzRemote, request)
File "/var/task/AlexaSmartHome.py", line 318, in handle_message
message = message[API_DIRECTIVE]
KeyError: 'directive'
UPDATE: All work now. just review di discovery test from Lamba function.
but from Alexa app no discovery the device anyway.
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Wednesday 12 December 2018 18:12
by DAVIZINHO
Congratulations!, this is awesome!!!
I hope apears a similar solution for google home
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Wednesday 12 December 2018 23:07
by Damsee
mvzut wrote: ↑Wednesday 12 December 2018 11:19
Ok, thanks!
Another question: if I send you the Domoticz JSON output of a motion sensor, can you then also implement that in the code? Wouldn't it be nice if Alexa could alert me to movement in and/or around the house at night? (Although the WAF will largely depend on the reliability of the sensor
)
That's not possible.
Remember that we use Alexa with DZ with the following idea :
> Asking Alexa one action/information > Alexa is asking DZ to do something or get the information > Alexa is giving you the feedback
What you're asking is the following :
> Something's happening with DZ (sensor or switch change) > DZ notifies Alexa > Alexa notifies you
That requires dual channel communication which is not implemented in Alexicz as it would require some configuration in DZ to notify Alexa.
And that would require many configurations steps to setup all devices to be able to notify Alexa for various things.
@Joys : I understand that your lambda function is OK but not the discovery through the APP ? never try that...
@mvzut : In order to debug the contact status option, could you set the debug option to 1 in the config file (configdz.json) and check the log on AWS through CloudWatch to see what's going on ? Thanks
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Thursday 13 December 2018 8:00
by manutremo
That can easily done from Domoticz using the alexa_remote_control.sh script. Search in Google for it for complete info.
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Thursday 13 December 2018 10:44
by rimram31
mvzut wrote: ↑Wednesday 12 December 2018 11:19
Ok, thanks!
Another question: if I send you the Domoticz JSON output of a motion sensor, can you then also implement that in the code? Wouldn't it be nice if Alexa could alert me to movement in and/or around the house at night? (Although the WAF will largely depend on the reliability of the sensor
)
Damsee answer you, this will require a different logic and perhaps architecture.
For now, Alexicz (and a lot of other Alexa skills ...) have only an Alexa (cloud) => skill request/answer logic (
https://developer.amazon.com/fr/docs/sm ... l-api.html) what you describe (having Alexa cloud notified by device changes) is the ChangeReport Smart Home API event:
https://developer.amazon.com/fr/docs/de ... angereport
To remain free, Alexicz use only a lambda function which can be triggered only on some AWS cloud events, not any stateful hosted components. Perhaps there may be a technical solution having our dz installation calling Alexa cloud having Alexicz sending some "skill context" informations and also sending/refreshing a required authentication token ...
This is not implemented at all for now.
@manutremo I don't understand how alexa_remote_control.sh can be useful for this. Performing an Alexa cloud call is a "simple" curl call but not so simple for such a call as the curl call require some context informations which are only known by the skill.
Alexicz - FREE Domoticz to Alexa Integration
Posted: Thursday 13 December 2018 10:55
by mvzut
Ok, clear, thanks for the explanation! I noticed indeed that a routine that starts with a door opening is not triggered.
By the way, when I view the state of a door contact in the Alexa app, it immediately changes as soon as I open the door. Is this because Alexa is continuously polling as long as this app page is visible?
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Thursday 13 December 2018 17:25
by rimram31
mvzut wrote: ↑Thursday 13 December 2018 10:55
...
By the way, when I view the state of a door contact in the Alexa app, it immediately changes as soon as I open the door. Is this because Alexa is continuously polling as long as this app page is visible?
Good question, but I've no answer. I've notice some Alexa cloud trafic when using an Alexa app, for example just after a discovery but this is not detailed in the official documentation.
This routine triggered from device activity was provided recently by Amazon. Implementing the skill, I've not understood at that time this "ChangeReport event" until this new feature comes
for sure this will be useful (I've some xiaomi motion sensors). I will try to investigate but I've not so much time to spend on this skill ... the community is free to use the code to improve it
Alexicz - FREE Domoticz to Alexa Integration
Posted: Friday 14 December 2018 10:41
by mvzut
I'm already super happy with the work you put in so far, nobody is expecting you to spend time on it you really don't have! I am willing to help, but my coding skills are pretty basic, and the complex architecture of the Alexa system is a bit too much for me from what I've seen so far. So I will probably mostly support with testing etc.
Speaking of which, I just tried if status updates are also reflected immediately in the Alexa app with regular switches. This is NOT the case, the status doesn't change when I switch the switch externally (e.g. from Domoticz). Could be related to the message in the top " There was a problem" that often appears, although I can always operate the switches either from the app or via voice commands.
If I may make one more observation?
Thermostats in the Alexa system seem to have a setpoint and an actual temperature. Since thermostats in Domoticz only have a setpoint, the actual temperature should actually remain empty, but in your implementation it gets the same value as the setpoint. Why is that? It leads to undesired effects, e.g. if I add a thermostat to a group (room) and I ask for the temperature in that group (room), Alexa will give me the AVERAGE temperature of all temperature sensors it finds in that room, including the (false) "actual temperature" of the thermostat.
UPDATE
It seems I can partly answer my own question here: I tried commenting line 56 in DomoticzHandler.py, which sets the actual temperature of the thermostat, but this causes errors in Alexa (cannot access the thermostat anymore). So apparently this variable NEEDS to have a value... I tried setting it to 0, which made the actual temperature magically disappear from the thermostat screen in the Alexa app! But Alexa still gives me the average temperature in the room, using also the 0 value (so 20.2 degrees becomes 10.1). Is there a way to tell the system this thermostat does not support actual temperature as a variable? Alternatively, it would be great if there was a way to use an actual temperature sensor in the same room for this, but then we would have to agree on a naming convention or something.
UPDATE 2
I commented line 190, this seems to do the trick! Alexa still mentions an "average temperature", even though there is only one sensor in the room, but at least now it is correct!
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Friday 14 December 2018 15:28
by rimram31
mvzut wrote: ↑Friday 14 December 2018 10:41
...
If I may make one more observation?
Thermostats in the Alexa system seem to have a setpoint and an actual temperature...
You're comment remember me that initially I've also wrote this script to be able to control thermostat temperature in my home . I've several "virtual" thermostat, "day rooms", "night rooms" and bath working with scripts I've wrote.
This was the more complex task of this skill ... Alexa thermostats are not simple =>
https://developer.amazon.com/fr/docs/sm ... vices.html with 1 to 3 possible setpoints and may report a temperature as a "temperature sensor" (this is what you remove commenting the line 190). You're right in the implementation I've done, a thermostat report as his temperature the current setpoint, this was acceptable for me
One of my disappointment implementing the skill is that I was never able to implement a: "Alexa make ... COLD/WARM..." This is partially related to my own dz installation/setup. I'm using dz thermostats only to manage setpoint temperatures (COLD, WARM ...) and a virtual switch to control heat mode (itself changed automaticaly by others, planned, switchs, but so can also be changed manually). The switch value is later used by other scripts to finally control heaters. So I've tried in the skill to be able to translate "Alexa make ... COLD/WARM" to -> set a Selector switch to ... one of the reason an Alexa_extra variable exists and some lines code (line 326,327 .... for example) which can appear strange.
I've finally abandoned.
In any case at least you may be able to control with Alexicz the setpoint temperature (and report it in my implementation ...). I don't know if there is a "sentence" to ask for the setpoint temperature, is this possible ?
Looking at this thermostat implementation, I've make some choices, perhaps a smarter implementation can be done.
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Friday 14 December 2018 15:34
by emme
for thermostat I've done it with NodeRed and Alexa-Home-Skill
it tooks me a while... but it's working good now
- Cattura-1.png (46.05 KiB) Viewed 3385 times
Alexicz - FREE Domoticz to Alexa Integration
Posted: Friday 14 December 2018 23:45
by joys
Damsee wrote:mvzut wrote: ↑Wednesday 12 December 2018 11:19
Ok, thanks!
Another question: if I send you the Domoticz JSON output of a motion sensor, can you then also implement that in the code? Wouldn't it be nice if Alexa could alert me to movement in and/or around the house at night? (Although the WAF will largely depend on the reliability of the sensor
)
That's not possible.
Remember that we use Alexa with DZ with the following idea :
> Asking Alexa one action/information > Alexa is asking DZ to do something or get the information > Alexa is giving you the feedback
What you're asking is the following :
> Something's happening with DZ (sensor or switch change) > DZ notifies Alexa > Alexa notifies you
That requires dual channel communication which is not implemented in Alexicz as it would require some configuration in DZ to notify Alexa.
And that would require many configurations steps to setup all devices to be able to notify Alexa for various things.
@Joys : I understand that your lambda function is OK but not the discovery through the APP ? never try that...
@mvzut : In order to debug the contact status option, could you set the debug option to 1 in the config file (configdz.json) and check the log on AWS through CloudWatch to see what's going on ? Thanks
I’ve resolved the problem for discovery via Alexa app. My problem was I had the “digital store” set to amazon.com. In fact I also found all Alexa public skill in English. I change my reference “digital store” to my country and all working fine. Also the public skill I found in app now are for my language. Thanks.
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Sunday 23 December 2018 23:46
by morilm
HI
I have been able to setup Alexicz successfully... Some work has been required to ensure the domoticz names are understand by Alexa when using the voice, specially if you try to make it work on a non ENG environment, but using the description helps a lot.
One improvement could be ability to proper selection between switches and lights to avoid to change it later in the alexa web.
On the documentation part, it could be simplified a little, as the configson file can be edited directly on the AWS control panel.
Happy to help anybody that get trap on the configuration part.
regards
Miguel
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Tuesday 25 December 2018 17:41
by philchillbill
Hi,
Great job on producing both the skill itself and the excellent how-to ! I have it running successfully and have been looking at some corner cases of the discovery. Some small observations not intended as a criticism:
I have devices with Type of Lighting1/2 and SwitchType of On/Off, Motion Sensor, Media Player, and Blinds Inverted. The current code will list everything that's Type Lighting1/2 and not On/Off as being of type 'Light', which is not strictly correct. It misses Motion, Media and Blinds corner cases.
Determining if something should have the dimmer capability added is currently too simple as it only checks for HaveDimmer. I have lots of devices where HaveDimmer is 1 but the device is not dimmable (no idea why, Domoticz did this itself). I found that
Code: Select all
hasDimmer = (device['HaveDimmer'] and (device['DimmerType'] != 'none')) or device['SwitchType'].endswith('Percentage')
catches the corner cases better. You can see this on the Echo Spot and Echo Show, where the switch icon on the screen shows a dimmer-slider if the device is considered dimmable by Alexa. It currently shows up (for me) for lots of non-dimmable devices but changing the code as above fixed this.
Any luck with getting the reporting of the door-contact state working? To catch all cases, the code should not just check for startswith 'Contact' but also 'Door Contact' as that is just as valid in Domoticz.
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Thursday 27 December 2018 18:37
by Damsee
Great you were able to setup Alexicz
morilm wrote: ↑Sunday 23 December 2018 23:46
I have been able to setup Alexicz successfully... Some work has been required to ensure the domoticz names are understand by Alexa when using the voice, specially if you try to make it work on a non ENG environment, but using the description helps a lot.
That's the same in french but this is how Alexa is understanding the different languagues
morilm wrote: ↑Sunday 23 December 2018 23:46One improvement could be ability to proper selection between switches and lights to avoid to change it later in the alexa web.
philchillbill wrote: ↑Tuesday 25 December 2018 17:41
I have devices with Type of Lighting1/2 and SwitchType of On/Off, Motion Sensor, Media Player, and Blinds Inverted. The current code will list everything that's Type Lighting1/2 and not On/Off as being of type 'Light', which is not strictly correct. It misses Motion, Media and Blinds corner cases.
You're both right as we setup Alexicz to be able to manage Domoticz devices being regardless about the code.
We did not find however a detailed list of all DZ devices including devices "type", devices "subtype" and devices "switchtype" which is a lot of possible device configurations that we have to match with Alexa available ones. And... there are very few Alexa devices regarding DZ devices : ACTIVITY_TRIGGER ; CAMERA ; CONTACT_SENSOR ; DOOR ; DOORBELL ; LIGHT ; MICROWAVE ; MOTION_SENSOR ; OTHER ; SCENE_TRIGGER ; SMARTLOCK ; SMARTPLUG ; SPEAKER ; SWITCH ; TEMPERATURE_SENSOR ; THERMOSTAT ; TV
philchillbill wrote: ↑Tuesday 25 December 2018 17:41Any luck with getting the reporting of the door-contact state working? To catch all cases, the code should not just check for startswith 'Contact' but also 'Door Contact' as that is just as valid in Domoticz.
We checked the code which is sent from Lambda to Domoticz and everything looks fine.
According
Amazon documentation, that feature is restricted to en-US Echo which might explain that feature is not working yet (has anyone the Echo setup in the US ?)
@philchillbill : we will have a look on the proposed improvement regarding the dimmer to check of drawbacks of that ; thanks for your help !
Alexicz - FREE Domoticz to Alexa Integration
Posted: Friday 28 December 2018 15:43
by philchillbill
I found it convenient to have all my Domoticz devices listed in the columns of an Excel sheet in order to check for the corner-cases. Using the data-filter in excel, it's easy to see all the relevant combinations. I used the following perl script to automatically build an excel file where each row is a device and the columns represent all the parameters. Blanks are automatically inserted if a device does not have a particular parameter. Feel free to use as a debugging tool:
Code: Select all
#!/usr/bin/perl
use JSON::XS;
use LWP::UserAgent;
use MIME::Base64;
no warnings 'uninitialized';
# Summarizes devices within Domoticz into an Excel Workbook, with blanks autovifified for any parameters
# that don't apply to a particular device (supersetted)
$url_domo='http://192.168.178.12:8080'; # change to your situation
$ua=LWP::UserAgent->new; $ua->timeout(5); $ua->env_proxy;
$response=$ua->get($url_domo.'/json.htm?type=devices');
$devices=$response->decoded_content;
$data=decode_json $devices; # all my domoticz devices as json
# build the superset of all parameter names across all devices
foreach $entry (@{$$data{result}}) { foreach $param (keys %{$entry}) { $params{$param}=1 } };
# now create an array of any parameters we want so see in the first columns of the excel
@showfirst=qw/idx Name Type SwitchType SubType HaveDimmer DimmerType/;
# add all the remaining parameters to the end of the array
%showfirst = map { $_ => 1 } @showfirst;
@params=@showfirst; foreach $entry (sort keys %params) { if (not exists($showfirst{$entry})) { push(@params, $entry) } };
# dump our excel file. The data in StrParam1 and 2 are base 64 encoded so decode for out file to make reading easier
open(OUT, '>', 'allmydevices.xls');
foreach $param (@params) { print OUT "$param\t" }; print OUT "\n"; # header line
foreach $entry (@{$$data{result}}) {
if (!$$entry{Used}) { next };
foreach $param (@params) {
if ($param=~m/StrParam\d/) { $$entry{$param}=decode_base64($$entry{$param}) };
print OUT "$$entry{$param}\t";
}
print OUT "\n";
}
close(OUT);
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Saturday 29 December 2018 13:22
by philchillbill
Another corner case. You can start a switch name with a '$' to have it 'invisible' on the Domoticz dashboard but still active. This is useful for switches used by scripts only and that will never be clicked by a human in the Domoticz UI.
The current discovery process will include the $ in the friendlyName, meaning you would have to ask Alexa to e.g. "turn on dollar bathroom music" instead of "turn on bathroom music". This can be avoided by adding the following line to DomoticzHandler.py:
Code: Select all
if friendlyName.startswith("$"):
friendlyName=friendlyName[1:]
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Saturday 29 December 2018 20:34
by rimram31
philchillbill wrote: ↑Saturday 29 December 2018 13:22
Another corner case. You can start a switch name with a '$' to have it 'invisible' on the Domoticz dashboard but still active...
Why not, this can be easily integrated. But you may note that you can change the name exported to Alexa defining
Alexa_Name in the description field of the device =>
Alexa_Name: xxxx
About device categorisation, the way domoticz handle device type is not very clear ... my main idea was to be "as large as possible" not to disable an available feature (dim, color) rather than taking a risk not to enable an existing feature. But you're welcome to find a better solution.
Re: Alexicz - FREE Domoticz to Alexa Integration
Posted: Saturday 29 December 2018 23:21
by Damsee
@philchillbil : thanks for the script but i can get my devices through DZ. It's more complicated to get all DZ devices type/subtype/switchtype.
You might PM Rimram or myself with your xls devices so we can check as you (and others) might have devices we don't have