bwssytems / ha-bridge

Home automation bridge that emulates a Philips Hue light system and can control other systems such as a Vera, Harmony Hub, Nest, MiLight bulbs or any other system that has an http/https/tcp/udp interface. This is a compact impl to run on small format computers. This is impl started from this project https://github.com/armzilla/amazon-echo-ha-bridge.
Apache License 2.0
1.45k stars 198 forks source link

Mochad/HA-Bridge/Pi Combo and Dimming #1057

Closed alzzy closed 5 years ago

alzzy commented 5 years ago

Hi! I am looking for some help getting Alexa to dim an x10 device to a spoken level using the cm19a interface with Mochad on an RPi. I have tried both these bridge dim item entries with no luck:

sh x10cmd rf a3 dim ${intensity.percent} and sh x10cmd rf a3 dim ${intensity.math(((X*-22)/255)+22)}

Has anyone been successful doing this and what dim item did you use? Thanks for any help!

audiofreak9 commented 5 years ago

I'm no MOCHAD expert, but why are you adding sh x10cmd to the command? I think simply rf a3 dim ${intensity.math(((X*-22)/255)+22)} would work.

alzzy commented 5 years ago

The x10 forum thread gives that syntax for on/off, which works fine, but it gives no command for a dim to a level. The dim command "sh x10cmd rf a3 Dim" dims a small fixed amount for each request but I am looking to dim by a % or to a level. Thanks for any help!

audiofreak9 commented 5 years ago

MOCHAD uses the construct pl <H><U> dim <Dims>, where <Dims> = 0..31 - Dim/bright range, 32 steps of dimming. So the math should be ${intensity.math(((X*-32)/255)+32)}. The 22 value would be used with HEYU, that has 0..21 <Dims>. Have you tried this directly from the command line first to validate that it works?

audiofreak9 commented 5 years ago

BTW I'm using the MOCHAD reference here.

alzzy commented 5 years ago

I'll have to research that to find out how to send command to mochad with ssh.

audiofreak9 commented 5 years ago

Is the HA-Bridge not on the same RPi the MOCHAD is installed on?

alzzy commented 5 years ago

Yes it is, but it was installed as part of an image on the Pi and I'm not sure how to access mochad directly. As you can guess, I am very new at this. Never used mochad before. If I enter the mochad item without the "sh x10cmd" directly into the bridge and test it from the bridge, it throws an error

alzzy commented 5 years ago

Well what I was originally looking for was Alexa voice control of x10 devices using a Pi zero W and a cm19a interface. I need to have dimming capability to a level not by a fixed amount. I tried to use an image from the Pi Alexa Project but it will not dim to a level as is and therefore needs some customization. After doing much googling I have reached the conclusion that I am not knowledgeable enough to do that customization myself. So if anyone has a solution to what I am trying to accomplish with a tutorial that a newbie like myself can follow, I would appreciate hearing about it. Thanks for any help!

audiofreak9 commented 5 years ago

First, can you please answer if you have tried the command rf a3 dim 15 (or whatever value you wish between 0 and 31) works directly from the command line? You state, "it will not dim to a level as is and therefore needs some customization", but I can't tell what you mean by that. MOCHAD will dim the device from 0% to 100% in 32 discrete dims. So the math in the above takes the 0 to 255 value from the HA-Bridge and converts it to a value from 0 to 31.

Second, you said you wanted, "Alexa voice control of x10 devices using a Pi zero W and a cm19a interface", do you have a physical Echo device? You cannot discover HA-Bridge devices without one. I'm wondering since you said you have Pi Alexa installed.

A few years ago, I wrote a tutorial on my site detailing how to do exactly what you want using HEYU rather than HOCHAD. Following my tutorial, all you need to do is install MOCHAD instead of HEYU at Step 2. You will also configure your devices using the MOCHAD commands rather than HEYU. Others in my comments have queried about using the CM19a, and I pointed all of them to MOCHAD, and a few have replied that they got it working with MOCHAD.

alzzy commented 5 years ago

Thanks for reponding!

When you say try entering command at the command line, what exactly do you mean? The command line after i log into Pi or do i need to cd to something and then enter the mochad command?

I have Echo dots both 2g and 3g and can discover devices.

How do the Mochad install steps differ from the Heyu install in your tutorial?

tuicemen commented 5 years ago

@alzzy you might find this thread interesting http://forums.x10.com/index.php?topic=22045.0 you don't state which type lamp module your using. However from the thread above it indicated a soft start module and a none soft start use different commands Since dim doesn't work you may wish to try xdim as that is designed to send a level.

audiofreak9 commented 5 years ago

@tuicemen

I am by no means a MOCHAD expert. Do you know if xdim works with rf? @alzzy is using the cm19a controller, I don’t think it can use xdim as far as I can tell.

@alzzy, if it does work then you don’t even need the math, since xdim can take values from 0 to 255.

audiofreak9 commented 5 years ago

Ahhh, it’s TCP on port 1099.

tuicemen commented 5 years ago

I don't do dimming though i do have a cm19 I use the cm15. I also use HomeGenie for X10 control and mochad and it conflict. The big problem with dimming and X10 is different lamp modules old and the newer softstart ones. MOCHAD from my understanding handles each differently. However I also I'm not a mochad expert, I only used it briefly while looking at Pi X10 solurions.

alzzy commented 5 years ago

@audiofreak9: When you say try entering command at the command line, what exactly do you mean? The command line after i log into Pi or do i need to cd to something and then enter the mochad command? Also, How do the Mochad install steps differ from the Heyu install in your tutorial? @tuicemen I'll play with xdim.

alzzy commented 5 years ago

xdim didn't work. thanks anyway!