Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H801: Seperate ON/OFF for all Channels "RELAY_PROVIDER_LIGHT" #457

Closed
xoseperez opened this issue Jan 23, 2018 · 17 comments
Closed

H801: Seperate ON/OFF for all Channels "RELAY_PROVIDER_LIGHT" #457

xoseperez opened this issue Jan 23, 2018 · 17 comments
Assignees
Labels
enhancement New feature or request light major
Milestone

Comments

@xoseperez
Copy link
Owner

Originally reported by: Michael Portz (Bitbucket: flashy02, GitHub: Unknown)


I'm trying to get one H801 work for different LED-Stripes, so it is necessary to control each channel separately.
At the Moment there is only ONE ON/OFF SW-Button witch powers all channels the same way. Additionally I would like to use Hardware-Buttons (e.g. GPIO0, GPIO3) for the old electric setting in my house.

My try to add 5 Relays and 5 Buttons in the hardware.h failed, because every Button on the Web Interface turns all 5 channels On/OFF as long as

#define RELAY_PROVIDER RELAY_PROVIDER_LIGHT.

Otherwise fading and dimming don't work.

@xoseperez xoseperez added this to the 1.13.0 milestone Jan 24, 2018
@xoseperez xoseperez removed the 1.12.1 label Jan 25, 2018
@xoseperez
Copy link
Owner Author

Yes, that not how it works. If you check the _relayProviderStatus method in relay.ino you will see that for the RELAY_PROVIDER_LIGHT it doesn't care what button or relay was triggered, it will just send the status to the light module.

This will require a minimum change in the relay module and a bigger one in the light module to store the on/off status per channel instead of having a global "status" variable.

@xoseperez xoseperez self-assigned this Jan 25, 2018
@flashy02
Copy link

Is there a plan to enhance the actual relay behavior? At the moment it is possible to define relays and buttons and connect them e.g. to Alexa as power plugs. So, if I use a ligh controller (e.g. H801) and connect it to Alexa it is also a power plug, and the light-functionality (dimming) can't be used.
It would be nice for the future to add an additional relay-type (e.g. #define RELAY#_TYPE: RELAY_TYPE_LIGHT_BULB) where it is possible to connect these relays as light bulb with Alexa to use on/off/dimming. Additionally there is the question how to use a HW-button in this mode if pressed: turning on/off the "relay" or powering up/down the pwm. (for all channels or each channel separately)

@xoseperez
Copy link
Owner Author

I will give it a try. For the moment it's assigned to milestone 1.13

@flashy02
Copy link

That sounds good. I'm curious about it.

@xoseperez
Copy link
Owner Author

Just pushed a preliminary support for this. This is how it works: basically, you have to define a number of dummy relays that matches the number of channels of your light. Then each relay will control the ON/OFF state of each channel. If you define one dummy relay more the first one will control all channels, just like now. Any other number of relays will make them behave just like now, they will all control all the channels.

Note these dummy relays behave just like normal relays, this means you can use MQTT also to control the channels.

This is kind of a hack so I wouldn't go further for the moment. Just give it a try and tell me if it's what you needed. It's in the dev branch.

Sample configuration:

#elif defined(HUACANXING_H801)

    // Info
    #define MANUFACTURER        "HUACANXING"
    #define DEVICE              "H801"
    #define RELAY_PROVIDER      RELAY_PROVIDER_LIGHT
    #define LIGHT_PROVIDER      LIGHT_PROVIDER_DIMMER
    #define DUMMY_RELAY_COUNT   5
    #define DEBUG_PORT          Serial1
    #define SERIAL_RX_PORT      Serial

    // LEDs
    #define LED1_PIN            5
    #define LED1_PIN_INVERSE    1

    // Light
    #define LIGHT_CHANNELS      5
    #define LIGHT_CH1_PIN       15      // RED
    #define LIGHT_CH2_PIN       13      // GREEN
    #define LIGHT_CH3_PIN       12      // BLUE
    #define LIGHT_CH4_PIN       14      // WHITE1
    #define LIGHT_CH5_PIN       4       // WHITE2
    #define LIGHT_CH1_INVERSE   0
    #define LIGHT_CH2_INVERSE   0
    #define LIGHT_CH3_INVERSE   0
    #define LIGHT_CH4_INVERSE   0
    #define LIGHT_CH5_INVERSE   0

@xoseperez xoseperez modified the milestones: 1.13.0, 1.12.2 Jan 26, 2018
@flashy02
Copy link

Thanks, I would get it a try, but at the moment i have a big problem to get the new git-repository to work. After cloning the rep i get a lot of problems, and if i try to build the h801 there comes only this failure message:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 122: ordinal not in range(128):
File "C:\users\mportz.platformio\penv\lib\site-packages\platformio\builder\main.py", line 158:
env.SConscript("$BUILD_SCRIPT")
File "C:\Users\mportz.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript.py", line 551:

return _SConscript(self.fs, *files, **subst_kw)
File "C:\Users\mportz.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript.py", line 256:
call_stack[-1].globals)
File "C:\users\mportz.platformio\platforms\espressif8266\builder\main.py", line 375:
target_elf = env.BuildProgram()
File "C:\Users\mportz.platformio\packages\tool-scons\script..\engine\SCons\Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "C:\users\mportz.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 63:
env.BuildFrameworks(env.get("PIOFRAMEWORK"))
File "C:\Users\mportz.platformio\packages\tool-scons\script..\engine\SCons\Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "C:\users\mportz.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 261:
env.ConvertInoToCpp()
File "C:\Users\mportz.platformio\packages\tool-scons\script..\engine\SCons\Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "C:\users\mportz.platformio\penv\lib\site-packages\platformio\builder\tools\piomisc.py", line 189:
out_file = c.convert(ino_nodes)
File "C:\users\mportz.platformio\penv\lib\site-packages\platformio\builder\tools\piomisc.py", line 54:
return self.process(contents)
File "C:\users\mportz.platformio\penv\lib\site-packages\platformio\builder\tools\piomisc.py", line 77:
assert self._gcc_preprocess(contents, out_file)
File "C:\users\mportz.platformio\penv\lib\site-packages\platformio\builder\tools\piomisc.py", line 88:
fp.write(contents)

@xoseperez
Copy link
Owner Author

Not sure this is related to ESPurna, can you build other projects?

@flashy02
Copy link

I don't konw, but espurna is actual the only project i use. With the bitbucket clone everything was fine, the only change was getting the clone from git.

@xoseperez
Copy link
Owner Author

Was it a fresh clone? The repo is the same, the only difference is the "provider".

@flashy02
Copy link

Yes, a fresh clone. That is the point I not understand. To check my IDE i've cloned the tasmota firmware. And what should I say, no problems.

@xoseperez
Copy link
Owner Author

I have just built the project for the H801 using IDE 1.7.1 / Core 3.5.1 under Windows and Core 3.5.1a7 under Linux. No problems...

What's the path to your new clone of ESPurna? Does it contain any non-ASCII character?

@flashy02
Copy link

That could be the dffference, my IDE is autoupdatetd, so i use the IDE 2.0.0 / Core ??? (Where can I find the Version?)

@flashy02
Copy link

The Path is the same as last time, so there schouldn't be a problem with non ASCII character.

@flashy02
Copy link

I'm not alone:
platformio/platformio-atom-ide#1444

@ivankravets
Copy link
Contributor

That was a bug in PIO Core 3.5.2a4 which we fixed in PIO Core 3.5.2a5. It was caused by switching to the latest SCons 3.0 which supports Python 3.0.
We need a lot of efforts to make all components working with Python 2/3. See platformio/platformio-core#895

Nevertheless, please open PIO IDE Terminal and type pio upgrade --dev. Now all should work without errors.

@flashy02
Copy link

flashy02 commented Jan 28, 2018

@ivankravets : Thank you for your help, it woked.
@xoseperez : Compiling worked, and the workaround works too. Thank you very much. For now I can give it a try in my home installation.

@xoseperez
Copy link
Owner Author

Nice. Will be released soon with 1.12.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request light major
Projects
None yet
Development

No branches or pull requests

3 participants