Announcing MQTT/Android bridging app: Zanzito. Beta testers wanted!

I’m unable to connect to my MQTT broker with TLS. In the Zanzito logs I see the following:

Not connected: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found

and in the Mosquitto log I see:

1494575238: New connection from x.x.x.x on port 1883.
1494575238: OpenSSL Error: error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown
1494575238: OpenSSL Error: error:140940E5:SSL routines:SSL3_READ_BYTES:ssl handshake failure
1494575238: Socket error on client , disconnecting.

I have already installed Owntracks on the phone and it is working just fine.

Hi, two things:

  1. I see the port is 1883: is that the port for TLS connections, in mosquitto configuration?
  2. Did you import the CA certificate in Android? (not through Owntracks, but at a system level)

Yes, I use 1883 for TLS.

And I did import the CA certificate at system level (you have to do that for Owntracks as well). It’s imported with use set to “VPN and apps”.

I did just try to change my mosquitto server certificate. I was using a certificate create from instructions in Owntracks, using a self-created ca certificate.
I switched to a server certificate from cacert.org. I’m still getting the same error with Zanzito, but Owntracks is working fine.
What I noticed was that Owntracks did give me the same error until I updated the path to the ca certificate file inside Owntracks. As far as I can see there are no option inside Zanzito to specify the ca certificate, could that be where the problem originate?

Would I be abusing if I asked you to share your configurations of zanzito? Is this even possible? So that maybe have some sort of cookbook for zanzito based on your work since i guess you are the one with more use cases onto zanzito :slight_smile:

Sure. I plan to share my examples once I get everything works perfectly. I am still in Work in Progress stage. I might share them in another thread so that I won’t flood this thread with unrelated posts.

@HVPereira

I have shared them at My Jarvis using Zanzito (Skills Collection)

Thank you so much!!

For TLS and MQTT the post should be 8883 is it not?

Not necessarily. The actual port is configurable and for practical reasons I use 1883.

Thanks.

How do you do a simple
Turn on the living room light
?

@MrMep

I’m wondering can zanzito do voice recognition? I notice Google Now can do that. Perhaps Google allows developer to have this via some kind of API?

The reason why is I want to protect the automation so that only certain people can issue the command.

Another possible usage is everyone in the house can use the same command “Where is my phone?”. The activity topic in zanzito would be %devicename%/%user%/chitchat with %user% being the variable set in zanzito. Each user will his/her own voice print in zanzito.

But how you do, if you do, to turn on a light or a switch?

It is needed an automation for each event?

For example turn on a light, you need an automation that if mqtt change state from off to on then you turn on the light?

Or there is something simpler?

Right now, I have this in my zanzito…

Activity #1

Name: Balcony Light
Topic: %devicename%/switch/light/balcony
Payload: on
Voice cmd: turn on balcony light

Activity #2

Name: Balcony Light
Topic: %devicename%/switch/light/balcony
Payload: off
Voice cmd: turn off balcony light

…and this is in my HA automation:

- alias: 'MQTT Switch'
  trigger:
    platform: mqtt
    topic: myphone/switch/#
  action:
    - service_template: >
        homeassistant.turn_{{trigger.payload}}
      data_template:
        entity_id: >-
          {{ trigger.topic.split('/')[-2] }}.{{ trigger.topic.split('/')[-1] }}
    - service: mqtt.publish
      data_template:
        topic: >-
          zanzito/{{ trigger.topic.split('/')[-4] }}/notification
        payload: >-
          {% set responses = [
          "OK",
          "Sure",
          "If you insist",
          "Done",
          "Alright",
          "No worries",
          "I can do that",
          "Leave it to me",
          "Consider it done",
          "As you wish",
          "By your command",
          "Affirmative",
          "No Problem"
          ] %}
          {% set rindex =  (range(0, (responses | length - 1) )|random) -%}
          {{responses[rindex]}}

As you can see, this is not the most ideal way to do it because for each switch/light/script that you want to control, you have to create 2 activities. If you have 50 items you want to control, you have to create 100 activities in total.

Right now, with the support of getting payload from vocal command, I am thinking of shrinking everything into one activity and one automation for every smart items in my house. Still work in progress. Faced some obstacles. Might need some advice here.

1 Like

EDIT, now I understand, you need two activities in Zanzito for each device you want to control

I do not understand how to publish the topic of the light … sorry mqtt newb here …

I mean how you connect th state

light.balcony_light

with a topic?

base on my automation, your mqtt topic must follow the entity ID.

For example, if your entity ID is light.balcony_light, then your topic must be %devicename%/switch/light/balcony_light.

More example…

light.livingroom1 —> %devicename%/switch/light/livingroom1
group.room_lights—> %devicename%/switch/group/room_lights
switch.room_fan—> %devicename%/switch/switch/room_fan

The automation will split up the last 2 levels and use it to form the entity id

{{ trigger.topic.split('/')[-2] }}.{{ trigger.topic.split('/')[-1] }}

1 Like

small bug,

in
activities
new topic
voice cmd,

it shows too few characters

1 Like

IT WORKS.

Ahahah I can turn on my lights in Italian …

Turn ON and OFF works great (which is enough, but just curious how to change STATE ATTRIBUTES, like brightness, colour …

@MrMep

not sure if this is available or programmed. Is it possible to create home shortcuts? This way you could fire up activities with one touch from home screen (sort of HTTP Shortcut program)