Giter VIP home page Giter VIP logo

Comments (36)

stefanbode avatar stefanbode commented on July 20, 2024

Currently not, but the idea is great. I have an Echo, too. Therefore testing is no problem. I would assume to use the dimmer value für the shutter. This might work. Let me do some investigations what is already implemented.

from sonoff-tasmota.

kouske avatar kouske commented on July 20, 2024

If you could map the dimmer value then it would be awesome! I will try to look into it as well (hope I can ramp quickly :))

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

For me it looks like currently the hue does not support dimming. Just of off as far as I can see in the code of the wemos/hue

from sonoff-tasmota.

kouske avatar kouske commented on July 20, 2024

It might be that the dimming option was not ported due to lack of space..

from sonoff-tasmota.

kouske avatar kouske commented on July 20, 2024

In file xplg_wemohue.ino, there is a function called HueLights which eventually parses a value called "bri".
This "bri" is later on sent to a function called LightSetHsb and I'm guessing it continues until we configure the hardware. Can we use this somehow? I just had a quick peek - not sure if this is even relevant but maybe, just maybe :)

from sonoff-tasmota.

nospam2000 avatar nospam2000 commented on July 20, 2024

Please test if my changes (see checkin above) fix your issue. At the moment it will only work correctly with shutters enabled, not with real lamps. It is not ready for a pull request, yet.

The shutters are shown as dimmable lamps in the Alexa App and show the current percentage. You can either set a percentage or switch it on/off which means 100% / 0%.

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

Great, I can promise my wife will love this. I checked already some code and have some question. Anyhow I will integrate this very soon. Here the list of questions:

  //STB mod
  //save old value in temp var
  bool on = power & (1 << (device-1));

  if(Settings.flag3.shutter_mode && (device > 0) && (device <= shutters_present)){
   // Need to check if this can really happen because alredy checked above
    //if((device < 0) || (device > shutters_present)) device = 1;
    // we go directly to the shutter_position. this holds the correct value and respect if the shutters are inverted
    bri = (float)(Settings.shutter_invert[device - 1] ? 100 - Settings.shutter_position[device - 1]: Settings.shutter_position[device - 1])/100.0f;
    on = bri  > 0; 
  }

Is the second IF really required? I think not because this is already checked before.
I changed to the shutterposition variable because this is already between 0..100 and reflect the current position and not the "to be" position. Also added the invert feature. Should be fine.

  //STB mod
  // please explain why you changed this
  response->replace("{s}", String((uint8_t)(253.0f * sat + 1.5f)));
  response->replace("{b}", String((uint8_t)(253.0f * bri + 1.5f)));
}

You changed the calculation and this might cause incompabilities with the original code. Therefore I want to understand the issue. With the new shutter_position bri can get a clear 1.0. As far I can see your calculation is 254.5 maximum instead of 254.0. Please explain what you have seen here as an issue.

if(Settings.flag3.shutter_mode) maxhue = shutters_present;

I will change this because with ONE shutter on relay 3 and 4 there could be additional functionality. I see no requirement to limit this, but for sure check not to work on "shutter_presents *2" relays, because these belong to the shutter

	//bri = (float)tmp / 254.0f;	
        bri = (float)tmp / 253.0f;
        if (resp) {
          response += ",";
        }
        response += FPSTR(HUE_LIGHT_RESPONSE_JSON);
        response.replace("{id", String(device));
        response.replace("{cm", "bri");
	//response.replace("{re", String(tmp));
        response.replace("{re", String((uint8_t)tmp));

Can you explain again the changes here to understand impact.

And last not least:

  //stb mode
  // intresting. is this a general problem or just with the shutter configuration?
  while(path->endsWith("/")) {                        // remove trailing "/"
    path->remove(path->length() - 1, 1);
  }

General problem or just your finding with the shutter. We can leave this in because it does not break anything.

from sonoff-tasmota.

nospam2000 avatar nospam2000 commented on July 20, 2024

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

Hi Michael, I'm now integrating your enhancement into my version. But I cannot get it worked even with your original file. I do see the item in Alexa home, but with status "Gerät reagiert nicht". Inside the log I do see the following errors. Any hint? Looks like the address already has an error.

13:22:03 HTP: Hue API (/rayuWQujJTNe3q4xGCrdhRAEJE4AuqkVoqPXzs2Q/lights/1)
13:22:03 HTP: Hue API ({"state":{"on":false,"bri":1,"alert":"none","effect":"none","reachable":true},"type":"Extended color light","name":"Marquise","modelid":"LCT007","uniqueid":"5c:cf:7f:24:60:a8:00:11-1","swversion":"5.50.1.19085"})
13:22:06 HTP: Hue API (/rayuWQujJTNe3q4xGCrdhRAEJE4AuqkVoqPXzs2Q/lights/1)
13:22:06 HTP: Hue API ({"state":{"on":false,"bri":1,"alert":"none","effect":"none","reachable":true},"type":"Extended color light","name":"Marquise","modelid":"LCT007","uniqueid":"5c:cf:7f:24:60:a8:00:11-1","swversion":"5.50.1.19085"})
13:22:08 HTP: Hue API (/rayuWQujJTNe3q4xGCrdhRAEJE4AuqkVoqPXzs2Q/lights/1/state)
13:22:08 HTP: Hue API ([{"error":{"type":901,"address":"/","description":"Internal Error"}}])
13:22:12 HTP: Hue API (/rayuWQujJTNe3q4xGCrdhRAEJE4AuqkVoqPXzs2Q/lights/1)

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

I checked out your latest change of the file from your repository with the same behavior. No changes here. Seems to be something general not working.

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

OK, found one bug. If you define more relays than friendly names the complete emulation does not work anymore. E.g. 5 relays defined. The you will get the error above. Now commands where send to sonoff and executed. But I did not get the correct value back to Alexa. The execution on the device works. Error at Aleca is "xxxx antwortet nicht" In the log it looks ok.

14:26:17 HTP: Hue API ([{"success":{"/lights/1/state/bri":255}}{"success":{"/lights/1/state/on":true}}])
14:26:17 Shutter 0: Real Pos: 800, Target 20000, source: Shutter, pos %: 0, direction: 1, rtcshutter: 9

14:26:18 CFG: Saved to flash at 3F8, Count 644, Bytes 3820

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

Hi Michael, to get rid of the rounding issues you should use the variable: Settings.shutter_position[i]
The benefit compared to your approach is that this variable only have INT from 0..100. Therefore no rounding problems here if you solve it once. In your approach:
(float)Shutter_Target_Position[device-1] / (float)Shutter_Open_Max[device-1]
is a real variable that can get whatever value with whatever rounding effects.

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

OK, still did not get it working BACK to Alexa. On the Tasmota side, everything looks ok. Also, the response for 40% on shutter1 make sense. 40% is bri:102. This is comming from arg(0) and also in the response. I have no idea, why Alexa claims "device xxx does not respond"


14:55:27 UPP: Hue 3 response packets sent to 192.168.178.96:58433
14:55:35 HTP: Hue API (/rayuWQujJTNe3q4xGCrdhRAEJE4AuqkVoqPXzs2Q/lights/1/state)
14:55:35 HTP: Hue POST args ({"on": true,"bri":102})
14:55:35 HueLights Before Path: /rayuWQujJTNe3q4xGCrdhRAEJE4AuqkVoqPXzs2Q/lights/1/state
14:55:35 HueLights Path: /lights/1/state
14:55:35 WebServer->args(): 1
14:55:35 WebServer->arg(0): {"on": true,"bri":102}
14:55:35 Alexa input 102
14:55:35 response: [{"success":{"/lights/1/state/bri":102}}{"success":{"/lights/1/state/on":true}}]
14:55:35 HTP: Hue API ([{"success":{"/lights/1/state/bri":102}}{"success":{"/lights/1/state/on":true}}])

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

Hi Michael, because I did you solution not working, I started from scratch with the original file and did my own research. I did not have these issues of calculation back and forward. With the values from 0..100 it works absolutely smooth. Additionally, I made all the changes that are required to work with inverted shutters and that there might be more than one shutter (you need to check the start relay for each shutter). Tested and checkedin. You can now also use Shutter1 and Schutter2 and Relay3 and Relay4. A mixed environment with shutter and lights works. The only thing you need to be aware of that Schutter2 must be at Relay5 and 6. Otherwise, you get into conflict with the maxhue_names.

from sonoff-tasmota.

nospam2000 avatar nospam2000 commented on July 20, 2024

from sonoff-tasmota.

nospam2000 avatar nospam2000 commented on July 20, 2024

Hi @stefanbode,

this is the log you should get if all is working correctly when setting it to 10%:

07:23:20 HTP: Hue API (/ca9f99/lights/1/state)
07:23:20 HTP: Hue POST args ({"bri":26})
07:23:20 lastsource 21: webgui:7
07:23:20 HTP: Hue API ([{"success":{"/lights/1/state/bri":26}}])
07:23:20 HTP: Hue API (/ca9f99/lights/1)
07:23:20 HTP: Hue API ({"state":{"on":true,"bri":26,"alert":"none","effect":"none","reachable":true},"type":"Extended color light","name":"Rollo 1","modelid":"LCT007","uniqueid":"dc:4f:22:ca:9f:99:00:11-1","swversion":"5.50.1.19085"})
07:23:20 CFG: Saved to flash at F6, Count 150, Bytes 3820
07:23:20 Shutter 0: Stopp Pos. 2000, relay: 0, pulsetimer: 0, rtcshutter: 20
07:23:20 RSL: SHUTTER1 = 10

Michael

from sonoff-tasmota.

nospam2000 avatar nospam2000 commented on July 20, 2024

I now re-added lamp support and inversion support to my branch.

My next steps are:

  • fix the emulation in the arendst:master branch
  • Support a mix of shutters and lamps

Michael

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

Hi @nospam2000, I don't want to blame you or ignore your efforts for the community. I had the same problem like you, that my Alexa was not excepting the requests correctly as written some posts before. Also everything was right in the code. Because I was not able to fix this I revert back to the original code and try to understand how the translation is working. I found out that for this use case I do not need a forward/backward calculation. I just send back the request value I got. Thats the reason my code is much smaller currently. Additionally, I want to support multiple shutters and the relays because my shutter has 2 lamps and two shutters connected. This needs to work. I assume that with my configuration the shuttervalue in the alexa app does not match the real position if I move my shutter without alexa. I tried two unmodified version of your code. The one you send and the latest that was in your repository. But I only substitute ONE file. Both files did not work with my Alexa. Even if it is also german. Do you make somewhere else changes? Also I found out, that in my current live version I have absolutely no problems with the 255 range and converting 0..100 into this range. Alexa excepts and executes on all values. Where is your recent code that should work?

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

One thing that makes is a bit easier to work on the 0..100 range is, that you convert from a smaller range into the wider range and back. This ensures you have less problems with rounding. The other way round it is way more complicated.

from sonoff-tasmota.

nospam2000 avatar nospam2000 commented on July 20, 2024

Hi @stefanbode

Because I was not able to fix this I revert back to the original code and try to understand how the translation is working

In the meanwhile I created a new branch for fixing the emulation support in the original arendst/master branch. There I added two unit test files for the conversions between the units.
Please see also my latest comment in arendst#3159.

My repository has changed. The problem was that I was unable to create a repository as a fork of arendst/Sonoff-Tasmota because I already have a fork of your repository.

I renamed my fork from your repo to Sonoff-Tasmota-Shutter and created a new one called just Sonoff-Tasmota which unfortunately is not marked as fork of arendst/Sonoff-Tasmota. The link to my shutter repo branch is now https://github.com/nospam2000/Sonoff-Tasmota-Shutters/tree/emulationSupport

I found out that for this use case I do not need a forward/backward calculation. I just send back the request value I got.

For the response this is easy, but Alexa polls the whole state just after the response to get the whole state. There you normally don't have the originally set value.

Additionally, I want to support multiple shutters and the relays because my shutter has 2 lamps and two shutters connected. This needs to work.

I understand and agree, but first the base must be working, then it can be enhanced. I'm still in the phase of understanding the Tasmota functionality and the code.

I assume that with my configuration the shuttervalue in the alexa app does not match the real position if I move my shutter without alexa.

When moving it outside Alexa you should never have a problem. Alexa just polls and accepts the new value.

When you start from scratch should at least comment out the parts of the response you don't need. Especially the cm and x/y in the original code should be removed.

I tried two unmodified version of your code. The one you send and the latest that was in your repository. But I only substitute ONE file. Both files did not work with my Alexa. Even if it is also german.
Do you make somewhere else changes?

I only commented out another trace, but I checked in that change 5 minutes ago.

Also I found out, that in my current live version I have absolutely no problems with the 255 range and converting 0..100 into this range. Alexa excepts and executes on all values.

This sounds like your Alexa is different from mine. It sounds strange, but it is not impossible. Can you please remove and re-add your devices in your next test (see steps 9 and 10 below).

Where is your recent code that should work?

Please see my git checkout command below in step 1.
The most recent version is always my best version :-)

Let me describe what I do to reproduce my environment. I did this now, so I don't have any artifacts. I also changed my CFG_HOLDER version to start up with a fresh configuration:

  1. git clone -b emulationSupport https://github.com/nospam2000/Sonoff-Tasmota-Shutters.git Sonoff-Tasmota-shutter-nospam2000

  2. copy my user_config_overwrite.h which contains the following settings (+WLAN):

#undef  CFG_HOLDER
#define CFG_HOLDER        4620
#undef EMULATION
#define EMULATION              EMUL_HUE
#undef MQTT_USE
#define MQTT_USE               0
  1. run build task PlatformIO:build (sonoff)

  2. upload firmware
    esptool.py --chip esp8266 --before no_reset --port /dev/cu.usbserial-A9IHT7ZR write_flash 0 ~/Downloads/Arduino/Sonoff-Tasmota-shutter-nospam2000/.pioenvs/sonoff/firmware.bin

  3. Go to web page: "Configure Module" = 07 Sonoff 4CH (which is my hardware)

  4. Go to web page "Configure other", MQTT=off, Hue Bridge=on, set names 1..4

  5. Logging serial=none, web=4 more debug

  6. console commands:

SETOPTION80 1
SETOPTION14 1
SETOPTION81 1
SHUTTERRELAY2 3
  1. go to https://alexa.amazon.de/spa/index.html#appliances and remove all existing Sonoff lamps for the device
  2. Say "Alexa suche neue Geräte"
  3. Say "Alexa Rollo 1 10%" which gives the following traces:
21:17:40 HTP: Hue API (/ca9f99/lights/1/state)
21:17:40 HTP: Hue POST args ({"bri":26})
21:17:40 lastsource 19: webgui:7
21:17:40 SRC: 
21:17:40 RSL: RESULT = {"POWER2":"ON"}
21:17:40 RSL: POWER2 = ON
21:17:40 HTP: Hue API ([{"success":{"/lights/1/state/bri":26}}])
21:17:40 CFG: Saved to flash at F9, Count 27, Bytes 3820
21:17:40 HTP: Hue API (/ca9f99/lights/1)
21:17:40 HTP: Hue API ({"state":{"on":true,"alert":"none","effect":"none","reachable":true,"bri":26},"type":"Extended color light","name":"Rollo 1","modelid":"LCT007","uniqueid":"dc:4f:22:ca:9f:99:00:11-1","swversion":"5.50.1.19085"})
21:17:41 Shutter 0: Real Pos: 2500, Target 2000, source: , pos %: 20, direction: -1, rtcshutter: 16
21:17:41 Shutter 0: Stopp Pos. 2000, relay: 1, pulsetimer: 0, rtcshutter: 20
21:17:41 RSL: SHUTTER1 = 10
21:17:41 SRC: 
21:17:41 RSL: RESULT = {"POWER2":"OFF"}
21:17:41 RSL: POWER2 = OFF
21:17:41 CFG: Saved to flash at F8, Count 28, Bytes 3820
  1. from the "Info" page:
Program Version | 6.1.1.13
Core/SDK Version | 2_3_0/1.5.3(aec24ac9)

/EDIT: first I forgot "SETOPTION80 1" in step 8, now it works

Can you please do the same so we have the same configuration, that means not only copy one file, but clone my whole repository so we have the same base?

Michael

from sonoff-tasmota.

nospam2000 avatar nospam2000 commented on July 20, 2024

@stefanbode,

which module type do you configure and which light_type + light_subtype is active?
Have you set "SETOPTION15 1?". The code behaves very differently depending on these 3 variables.

Michael

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

I use a generic ESP8266. In special a WEMOS D1 mini. It worked with Setoption15 ON and OFF. No issues here. what about the different light types. Where can I configure this one because I have not configured anything

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

I double checked my code. And it looks there is a two-way communication. Whenever I change the shutter on the Web frontend. I can see the correct value immediately in the Alexa App. So it seems to be something with the light types.

from sonoff-tasmota.

nospam2000 avatar nospam2000 commented on July 20, 2024

the light_type + light_subtype are set in sonoff.ino:GpioInit() automatically depending on the selected module type and depending on SETOPTION15.
For example :

  if (Settings.flag.pwm_control) {
    for (byte i = 0; i < MAX_PWMS; i++) {
      if (pin[GPIO_PWM1 +i] < 99) light_type++;  // Use Dimmer/Color control for all PWM as SetOption15 = 1
    }
}
[...]
  else if (SONOFF_BN == Settings.module) {   // PWM Single color led (White)
    light_type = LT_PWM1;
  }
  else if (SONOFF_LED == Settings.module) {  // PWM Dual color led (White warm and cold)
    light_type = LT_PWM2;
  }
  else if (AILIGHT == Settings.module) {     // RGBW led
    light_type = LT_RGBW;
  }
  else if (SONOFF_B1 == Settings.module) {   // RGBWC led
    light_type = LT_RGBWC;
}

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

I have two shutter modules. One production and one for testing. Both are Wemos D1 mini. Also selected in the Configuration tab. The production one has two shutters, 2 Relays and PWM1,PWM2,PWM3 for an LED stripe with setoption15=0. My test module only has 2 shutters and two relays. Both modules work fine with the minimal changes in the WEMOSHUE file and without a complicated forward backward calculation. I do see not issues currently and as mentioned before also the reporting back of the actual position works. This will send back AFTER the shutter stops. During operation, you still see the old value. Also from time to time there is 1% difference between what you requested and what you get. But this is also fine because it is not possible to stop the motor in any condition exactly at the requested position.

from sonoff-tasmota.

nospam2000 avatar nospam2000 commented on July 20, 2024

SB> Also from time to time there is 1% difference between what you requested and what you get
This is exactly the rounding issue which leads to the very annoying Alexa message "Das Gerät funktioniert nicht richtig" when you use the voice command. When you use the Alexa app, you will only see a small note for 2 seconds that there is a problem with the device.
It has nothing to do with the time, but is reproducable for specifc values (use my unit tests with your formula and you will see which values).

SB> During operation, you still see the old value

Which will also lead to the Alexa error message from above. For sure you can ignore that error message, but the WAF for the voice commands will be very bad when you always get such error messages.

My question was: when you use my version, what problem do you see?
How does you log look like (with command and response, like the one I posted)?

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

I currently cannot use your code because already on the 6.2 release. Will do ASAP. My Alexa complains nothing so far. Always get the OK. And Themis operates

from sonoff-tasmota.

B1G1 avatar B1G1 commented on July 20, 2024

Hi, i bought an echo dot and i would like to use Alexa to open the shutters but i don’t understand how configure the Hue emulation. Con you help me?

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

Hi Bigi,

I do not know, if the Alexa integration currently works. It worked but then there were some changes.... It normally works like a dimmer. You set a name like "shutter kitchen" and then say "shutter kitchen to 50 percent". This was the idea and how it should work.

from sonoff-tasmota.

B1G1 avatar B1G1 commented on July 20, 2024

Well, I solved by integrating Home Assistant in alexa using this https://github.com/mike-grant/haaska
Now I can manage with the voice all the devices I have, including the shutters

from sonoff-tasmota.

micdg96 avatar micdg96 commented on July 20, 2024

Is there any possibility to change the shutter percentage through Google Assistant?

from sonoff-tasmota.

lollul avatar lollul commented on July 20, 2024

Is there any possibility to change the shutter percentage through Google Assistant?

Yes, I've been using GA/Google Home for a couple of months now via gbridge.io. While there appears to be unofficial support in Google Home for shutters/blinds they are not supported yet on Google Home app (only voice commands work). So, I've set up my shutters as 'lights' in gbridge with Brightness and OnOff traits. Then I'm using a little mosquitto_sub/mosquitto_pub script to 'translate' gbridge topics to Stefan's Tasmota shutters topics.
E.g. I translate 'onoff' from gbridge with payload 0 to SHUTTERCLOSE and 'onoff' with payload 1 to SHUTTEROPEN.
I guess this translation could probably be avoided...may need a new command in Stefan's Tasmota though. There could be better way to do this of course.
I simply decided to wait for official shutter/blinds support in GA and I'm fine with my hackish translation for now.

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

Best case you check how people are doing it with homeassistant. There are some nice examples. To work on a common topic for the shutter I would suggest to use the BACKLOG topic and then the commands (SHUTTEROPEN/SHUTTERCLOSE/SHUTTERPOSITION=30.... as a payload.As mentioned see the wiki with the homeassistant implementation. Should be very similar.

from sonoff-tasmota.

DasLemo avatar DasLemo commented on July 20, 2024

Hi, I hope it's okay i use this thread. Is the Alexa support currently broken? I know it was broken a while ago because Amazon changed something about the Hue-Support. Since then it worked again for me to pull the shutters completely up and down again but I am not able to close or open it toa certain percentage. I'm using the newest release (Sonoff-Tasmota 6.6.0.1 stb-1.5 by Theo Arends) but can't get it to work.
Best regards!

from sonoff-tasmota.

stefanbode avatar stefanbode commented on July 20, 2024

Thanks for the feedback. The current update has several changes to the hue emulation. This might cause a breakdown. I was not able to test this yesterday. But will do soon, if you say the percentage does not work anymore.

from sonoff-tasmota.

timmaeh avatar timmaeh commented on July 20, 2024

It do not work either for me. Says something like "the device does not support this".

Just waiting for a version with alexa support :-)

from sonoff-tasmota.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.