Something new

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Foune
Experienced User
Posts: 96
Joined: Sun Jul 03, 2011 7:08 pm

Re: Something new

Post by Foune » Mon May 22, 2017 2:51 pm

Just for information, will you use some of the esp easy library source code for your new library?
kgschlosser, maybe you could rename the title of this thread?

User avatar
kgschlosser
Site Admin
Posts: 5021
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Something new

Post by kgschlosser » Mon May 22, 2017 3:16 pm

never stated i was going to use the esp easy. I was also throwing an idea out there to see if people would use something like this. I have not done any work on it as of yet but if an interest increases i would consider making something
If you like the work I have been doing then feel free to Image

pearbear
Experienced User
Posts: 150
Joined: Mon Apr 02, 2012 10:28 pm
Contact:

Re: Something new

Post by pearbear » Mon May 22, 2017 3:19 pm

My library EtherEvent is only intended to allow microcontrollers to send or receive events using the EventGhost Network Sender/Receiver communications protocol. The choice of how to react to received events or generate events to send is up to the user, they must write their own code for that. This is actually more easy than you might expect because there is good support for programming the ESP8266 using the Arduino IDE.

ESP Easy is a turn key firmware solution so it's much more easy to use but also less flexible. They have a specific range of supported actions and accessories. If you need to do something else then you will have to dig into their code and make the necessary modifications. Features you don't use are just sitting there wasting memory, though luckily the ESP8266 has quite a bit of that as microcontrollers go.

Foune
Experienced User
Posts: 96
Joined: Sun Jul 03, 2011 7:08 pm

Re: Something new

Post by Foune » Tue May 23, 2017 7:13 am

All right, I didn't know your project, very interesting. I wonder how the wifi will be managed. I guess I'll have to use both your EtherEvent and asp easy librairies to get the sonoff working with my setup.

Well, let's wait and see.
In the same time, I'm following a french automationer who is designing and coding a "universal" open source zigbee gateway. For now, he can control xiaomi, pluzzy and Philips Hue devices, it is already more than I expected!

Maybe this could interest you, with the help of google translate (unless you speak french) : http://faire-ca-soi-meme.fr/domotique/2 ... e-gateway/

pearbear
Experienced User
Posts: 150
Joined: Mon Apr 02, 2012 10:28 pm
Contact:

Re: Something new

Post by pearbear » Tue May 23, 2017 12:35 pm

Foune wrote:I wonder how the wifi will be managed.
Arduino libraries tend to have a consistent API. All well designed network communication libraries use the same Client and Server class so the user can create the client object and then pass it to the library. The library can treat that object generically. Currently I have the user pass the Server object to availableEvent() and then create the Client object in the library. The reason for this is that it makes things as simple as possible for the user, which was my specific goal for the library. However, I have not found any way to create the Client object in a generic manner, this code in the library is specific to the Ethernet library. So to add support for other network communication libraries I only need to require the user to create the Client object in their code and pass it to the library. This only requires them to add a couple extra lines of code so it's not really a huge problem but it does break backwards compatibility. Luckily I don't think anyone except for me actually uses the library so this won't cause much breakage but I do have to update the code I use in my home automation system to handle the new API.
Foune wrote:I guess I'll have to use both your EtherEvent and asp easy librairies to get the sonoff working with my setup.
Why can't you use ESP Easy alone?

Foune
Experienced User
Posts: 96
Joined: Sun Jul 03, 2011 7:08 pm

Re: Something new

Post by Foune » Tue May 23, 2017 2:14 pm

Because I'm looking for an ack system like yours. Before reading your work I had planned to customize the esp easy HTTP module in order to get an ack in the HTTP response status code.

pearbear
Experienced User
Posts: 150
Joined: Mon Apr 02, 2012 10:28 pm
Contact:

Re: Something new

Post by pearbear » Tue May 23, 2017 2:50 pm

OK, that makes sense. Here's the queue library that goes along with EtherEvent, which has the ACK system:
http://github.com/per1234/EtherEventQueue

You also might consider using MQTT instead since apparently that is already incorporated in ESP Easy. I believe at some QoS levels there is an ACK system built into MQTT. You would need to check if the necessary QoS level is supported by both ESP Easy and the EventGhost MQTT plugin (or whatever you're using on the PC side) as I have seen that some software does not support all QoS levels.

Foune
Experienced User
Posts: 96
Joined: Sun Jul 03, 2011 7:08 pm

Re: Something new

Post by Foune » Tue May 23, 2017 3:09 pm

As far as I know, there is no such ack feature in mqtt. I'm already using mqtt and I just see this as a broadcast message system.
I could also set up a custom ack system in e.g based on MQTT : I throw a command and I wait/retry until I get a response, but using an asynchronous method would bring a lot of drawbacks.
My second option is to rely on the HTTP + TCP/IP requests, I just check that the HTTP response is OK to consider the order was transmitted. Which would be the simplest and fastest method. As I don't expect more than actuating on/off sonoff switches, this would be reliable enough.

Foune
Experienced User
Posts: 96
Joined: Sun Jul 03, 2011 7:08 pm

Re: Something new

Post by Foune » Wed May 24, 2017 7:40 am

I was wrong, there is a MQTT QOS mechanism that looks rather advanced. But because MQTT uses a broker, failing to deliver a message to a client isn't transmited to the sender, this is what I understand when reading this : http://www.hivemq.com/blog/mqtt-essenti ... ice-levels , especially this question and answer :
Abhinaya says: Hi , I have a doubt when i’m publishing the messages, receiver not receiving that message but broker sends ACK to me(sender) message was successfully delivered. How can I know the message reached to receiver or not?
The HiveMQ Team says: Hi Abhinaya, that is a great question. You won’t get notified when the receiver (or better: the receivers) received the message from the Broker you just sent to the Broker. If you would like to get notified, you must implement such a mechanism yourself on top of MQTT (e.g. by sending messages to different topics).

Hope this helps,
Dominik from the HiveMQ Team

MQTT brings more complexity.

pearbear
Experienced User
Posts: 150
Joined: Mon Apr 02, 2012 10:28 pm
Contact:

Re: Something new

Post by pearbear » Wed May 24, 2017 8:24 am

Foune wrote:MQTT brings more complexity.
Yeah, I started with the idea of using MQTT in my system but at that time I found I didn't like adding the concepts of subscribing and publishing to topics and using brokers on top of EventGhost's event/payload paradigm. I wanted to be able to just say "send this event and payload to that IP address", which was the motivation for writing my own library.

Foune
Experienced User
Posts: 96
Joined: Sun Jul 03, 2011 7:08 pm

Re: Something new

Post by Foune » Wed May 24, 2017 8:50 am

That's true. e.g is already a multi-protocol "broker" to me.
I had to install a MQTT broker in order to get domoticz talking with e.g. I wish e.g had it's own broker, so that I wouldn't have had to deal with a third party software. Maybe I could have upgraded the MQTT QOS system in order to improve the trasmit failures...
Anyway, I'll focus on a basic HTTP communication between e.g and ESP. Will be better than nothing.
I'll read about the other features of esp easy library, particularly the esp-to-esp direct communication.

User avatar
kgschlosser
Site Admin
Posts: 5021
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Something new

Post by kgschlosser » Thu May 25, 2017 7:49 pm

I personally feel that MQTT has far to many complexities to be used for anything home automation related. to complex to set up to complex to use. and from my reading has a far amount of inconsistency. and Domoticz I have started to use as well. but it's python plugin side of things is not complete. or may never be complete. There is no way to access the information contained within Domoticz from the python environment they set up. it is limited to creating objects that can be placed into domoticz and you can access information for that object. but there is no way to access information about an already existing object. I was stoked to make a plugin to directly talk to EventGhost without the need of something like MQTT but their software will not allow it. and their support has much to be desired. as well as how their software handles updates. which is a really odd thing because it will not accept updates from a device. it will only do updates when it specifically asks for them. as an example. set a polling rate for a zwave device to 60 seconds. then turn a light switch on. now the device notifies domiticz that it is now on. but domoticz does nothing with that information. so you see no status changes. not until that 60 second poll time is up. then it will ask the device. and the device responds with the changes and then it will show the light is on. and even that polling time of 60 seconds doesn't happen at 60 seconds. sometimes it is a minute and a half. other it is 70 seconds. it seems to do it whenever it has the free time. I personally thought that the performance should/would have been a lot better because of running on a PC. it appears as tho at some point i am going to have to dive into zwave and make something up to run on EG. but as pearbear had stated it is nicer to do a simple point to point transfer.

@pearbear what would be the process to possibly get etherevents added to easy esp?
If you like the work I have been doing then feel free to Image

pearbear
Experienced User
Posts: 150
Joined: Mon Apr 02, 2012 10:28 pm
Contact:

Re: Something new

Post by pearbear » Thu May 25, 2017 9:10 pm

I had a browse through the ESP Easy source:
https://github.com/letscontrolit/ESPEasy/tree/mega/src
and it doesn't look terribly easy. Ideally the necessary changes could be merged into their project, otherwise it makes it a lot of work to keep synced with their development. That could be a tough sell though. The UDP, webserver, and MQTT protocols they currently use are much more generally useful. The Network Events Sender/Receiver protocol is limited to EventGhost. a few mobile apps, and Arduino's using EtherEvent. They're already struggling to make the firmware fit on the ESP-01 modules with 512 kB of flash. They might be more receptive if all the EtherEvent code was wrapped in preprocessor conditionals so there is no overhead if it's not enabled. Of course doing that makes the code harder to maintain and test.

One thing is for sure, the first step is to get EtherEvent working on ESP8266. Unfortunately I've run into a setback because my main computer is out of action with hardware problems and I'm limping along with an ancient Pentium now that is super unreliable. So I can't get back to work developing until I either manage to fix it or give up and replace it (which means spending days getting everything installed and configured).

Foune
Experienced User
Posts: 96
Joined: Sun Jul 03, 2011 7:08 pm

Re: Something new

Post by Foune » Tue Jun 20, 2017 8:12 am

Good news!

I played with esp easy and tasmota, on my TH10 basic sonoff modules, on my sonoff touch module as well.Tasmota is clearly the best sonoff firmware for most enthousiast automationers, the work is still in progress. Last revision added longpress support, in addition to single and double click.

The system appears to be reliable, with a fallback behaviour in case the MQTT server does'nt respond.

The sonoff touch is a very very interesting product, allowing a lot of possibilities for only 12$. Clones are appearing on the chinese market, having multiple buttons, design, but still based on the esp 8285 chip (the sonoff touch use a 8285 instead of 8266, Tasmota adapts its compilation accordingly).

Tasmota : https://github.com/arendst/Sonoff-Tasmota
Description of button events : https://github.com/arendst/Sonoff-Tasmo ... tton-usage
Recent upgrade for multiple press (read the bottom) : https://github.com/arendst/Sonoff-Tasmota/issues/200

Sonoff touch flashed in 5mn, no soldering.
Image

Dark bad quality pic
Image

Don't seems to be high quality design and components but at least there is a fuse
Image

Tasmota naturally integrates with domoticz, using the mqtt topics domoticz/in and domoticz/out .
I'd like to decode and use in eventghost the native MQTT sent by the sonoff stuff :

cmnd/second_sonoff/POWER TOGGLE
cmnd/sonoff/POWER HOLD
cmnd/livingroom_ceiling/POWER ON|OFF

My problem is I still don't understand how I should organize the different sonoff modules using the variables Topic, GroupTopic, ButtonTopic and SwitchTopic. As far as I understand, I should create a dedicated topic for each module, then subscribe to each topic from eventghost. I would have done something different, for instance all modules subscribe to a unique topic, for instance sonoff, adding the sonoff "id" behind, for instance sonoff/living_room/POWER HOLD

User avatar
kgschlosser
Site Admin
Posts: 5021
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Something new

Post by kgschlosser » Tue Jun 20, 2017 12:02 pm

I am not up on how MQTT runs. but I do know that the chip you have can be flashed with a whole slew of different firmware.

It would be very easy to flash micropython onto it and create a network sender/receiver plugin for micropython and be able to communicate directly between EG and the module without the need for MQTT

but using MQTT is beyond my knowledge
If you like the work I have been doing then feel free to Image

Post Reply