drakhart / ha-super-soco-custom

Custom component for integrating your Super Soco or Vmoto Soco motorcycle into Home Assistant. It provides meaningful data like power status, battery percentage, location and a lot more.
MIT License
16 stars 3 forks source link

Vmoto app #17

Open darkner258 opened 4 months ago

darkner258 commented 4 months ago

Hello, does this integration work with the new Vmoto (not Soco) app? And if not, is support planned?

apbarratt commented 3 months ago

Aha, I was actually just on my way here to make a feature request as I just discovered the new app. Yes, the app works with the Super Soco App if your bike has the old style module using 3G, and it also works with the Vmoto app if you have the new module. But what I discovered yesterday is that there are actually two versions for the Vmoto module available on my iPhone at least, both seem to just be called Vmoto but the icon for the one I've been using to date says "VmotoSoco" and is black. I recently discovered that my data module's subscription had finally expired and that whilst the VmotoSoco app I was using was able to show when its inclusive subscription started, it provided no method of renewing it. The white icon Vmoto app on the other hand showed an expiry date and a few more data points that have proved interesting but most importantly I was able to renew my subscription.

Anyway, it's important to note that only one session at a time works with your account, but once you have your home assistant app set up the way you like it, you'll likely find yourself not wanting to open either of the official apps anyway :)

darkner258 commented 3 months ago

Thats true, but what I have noticed is that the HA integration doesn't refresh. As you said, as soon as I configure a session in HA, the one in the white Vmoto app expires and after that, if I don't do a manual reload of the integration, I don't get any notifications, unlike from the Vmoto app which does send them. Refresh time is set to one minute, but I have had the same data for an hour.

st 22. 5. 2024 v 11:00 odesílatel Andy Barratt @.***> napsal:

Aha, I was actually just on my way here to make a feature request as I just discovered the new app. Yes, the app works with the Super Soco App if your bike has the old style module using 3G, and it also works with the Vmoto app if you have the new module. But what I discovered yesterday is that there are actually two versions for the Vmoto module available on my iPhone at least, both seem to just be called Vmoto but the icon for the one I've been using to date says "VmotoSoco" and is black. I recently discovered that my data module's subscription had finally expired and that whilst the VmotoSoco app I was using was able to show when its inclusive subscription started, it provided no method of renewing it. The white icon Vmoto app on the other hand showed an expiry date and a few more data points that have proved interesting but most importantly I was able to renew my subscription.

Anyway, it's important to note that only one session at a time works with your account, but once you have your home assistant app set up the way you like it, you'll likely find yourself not wanting to open either of the official apps anyway :)

— Reply to this email directly, view it on GitHub https://github.com/drakhart/ha-super-soco-custom/issues/17#issuecomment-2124243912, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZKVEULTJDMHOPQOPCJGHI3ZDRNCRAVCNFSM6AAAAABICE3FMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRUGI2DGOJRGI . You are receiving this because you authored the thread.Message ID: @.***>

apbarratt commented 3 months ago

Oh that's curious. I wonder if there might be some additional configuration you might need to do. If you click Configure on the integration itself, what do you find? Screenshot 2024-05-22 at 12 27 48 It's also important to remember you need to create automations to forward notifications to your phone, but that wouldn't explain the lack of data updates you've described. I'd also wonder if your data subscription has expired, but if you're saying you do still see updates in the official app, that seems unlikely to be the issue here.

darkner258 commented 3 months ago

So, a few findings

1) In the config, I see what you see, only difference is the refresh time on mine being set to 2 minutes (I tried to re-flush the config) 2) Data does refresh, battery just dropped. Seems that in HA, the state update time moves only when the state itself actually changes 3) Now it seems the only problem are the notifications. How do I forward them? I might be missing something obvious

st 22. 5. 2024 v 13:33 odesílatel Andy Barratt @.***> napsal:

Oh that's curious. I wonder if there might be some additional configuration you might need to do. If you click Configure on the integration itself, what do you find? Screenshot.2024-05-22.at.12.27.48.png (view on web) https://github.com/drakhart/ha-super-soco-custom/assets/642320/2298f445-1799-49e2-b668-917eea7b9432 It's also important to remember you need to create automations to forward notifications to your phone, but that wouldn't explain the lack of data updates you've described. I'd also wonder if your data subscription has expired, but if you're saying you do still see updates in the official app, that seems unlikely to be the issue here.

— Reply to this email directly, view it on GitHub https://github.com/drakhart/ha-super-soco-custom/issues/17#issuecomment-2124571995, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZKVEUO6NTIRDK4ECKM33N3ZDR7CBAVCNFSM6AAAAABICE3FMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRUGU3TCOJZGU . You are receiving this because you authored the thread.Message ID: @.***>

apbarratt commented 3 months ago

You can create an automation to handle notifications quite easily based on using the "last warning" sensor as a trigger. Here's the one I've written:

alias: Bike Alerts and Logging
description: Relay all bike alerts to Andy as critical.
trigger:
  - platform: state
    entity_id:
      - sensor.bike_last_warning
condition: []
action:
  - service: logbook.log
    data:
      name: "{{ trigger.to_state.attributes.title }}"
      message: "{{ trigger.to_state.attributes.message }}"
      entity_id: sensor.bike_last_warning
      domain: alert
  - choose:
      - conditions:
          - condition: template
            value_template: |-
              {{
                trigger.to_state.attributes.title == "burglar alarm"
                or
                trigger.to_state.attributes.title == "防盗报警"
              }}
        sequence:
          - service: notify.andy
            data:
              title: Bike Alarm
              message: The bike detected motion whilst locked... supposedly.
            enabled: false
        alias: Alarm
      - conditions:
          - condition: template
            value_template: >-
              {{ trigger.to_state.attributes.title ==
              trigger.from_state.attributes.title }}
        sequence:
          - service: notify.andy_with_critical
            data:
              title: "{{ trigger.to_state.attributes.title }}"
              message: "{{ trigger.to_state.attributes.message }}"
        alias: Other warnings that are different to last warning
mode: single

In this one I've separated the notifications up so I receive critical notifications for pretty much everything but the burglar alarm, which I found went off entirely too often, so I told it to use less critical notifications (although you'll be able to see I've just gone ahead and disabled alarm notifications all together for now). A light breeze sets mine off for example. One day I'll figure out how to turn down its sensitivity.

You'll also notice I detect that using both English and Chinese, because there have been the odd occasion when the Vmoto servers have started sending out messages in Chinese for some reason.

Now my notification part will look odd, that's because I created two notification groups so I don't have to fill in all the notification service data or remember the full entity ID for my phone every time I need it 😅 Here's what those groups look like in my config files:

notify:
  - platform: group
    name: andy
    services:
      - service: mobile_app_andy_barratt_s_iphone
  - platform: group
     name: andy_with_critical
     services:
      - service: andy
         data:
           data:
             push:
               sound:
                 name: default
                 critical: 1
                 volume: 0

It's important to note that the critical notification settings there are specific to iPhone/iPad. If you use Android, it's a different set of options so you'll need to tweak accordingly :)

darkner258 commented 3 months ago

Awesome, thanks! I'll try this out :)

apbarratt commented 3 months ago

@darkner258 How did you get on? :) I thought I might try and add some docs in a PR some time soon with some example automation stuff like this :)

darkner258 commented 3 months ago

Well I have managed to get the non critical notifications working, but the critical ones are still not getting through. Below is my Yaml, do you see any mistakes there? I have simplified it a bit to include the notifications in the automation itself

alias: Bike Alerts and Logging description: Relay all bike alerts to Andy as critical. trigger:

apbarratt commented 3 months ago

It's hard to tell with this formatting as the indentation is difficult to spot, if you wrap your code with a line of triple back ticks (i.e. ```) it'll be easier to read, but if I'm right in assuming your mobile phone is not an iPhone, I expect that's the primary issue we need to sort here as Android uses a different set of options.

The HomeAssistant docs example gives this for iPhone:

- service: notify.mobile_app_<your_device_id_here>
  data:
    title: "Wake up!"
    message: "The house is on fire and the cat's stuck in the dryer!"
    data:
      push:
        sound:
          name: "default"
          critical: 1
          volume: 1.0

Whereas the same for Android looks like this:

- service: notify.mobile_app_<your_device_id_here>
  data:
    title: "Wake up!"
    message: "The house is on fire and the cat's stuck in the dryer!"
    data:
      ttl: 0
      priority: high

The docs also give a few additional interesting options for Android, such as an "alarm stream" that can make your phone vibrate or make noises or even speak words even when the phone is set to stay silent. https://companion.home-assistant.io/docs/notifications/critical-notifications/#:~:text=Critical%20alerts%20always%20appear%20at,notification%20rate%20limits%20as%20well.

Hope this comes in handy :)

apbarratt commented 3 months ago

[sniggers] I just copy pasted and only just spotted the words "Wake up!" "The house is on fire and the cat's stuck in the dryer!" and now think someone had entirely too much fun writing those docs 😆

drakhart commented 3 months ago

Just to add to this conversation and confirm Andy's notes on Android, this is my automation for relying alarms to my Android phone:

alias: Notify bike alerts
trigger:
  - platform: state
    entity_id: sensor.super_soco_tcmax_last_warning
    not_from:
      - unavailable
condition:
  - condition: state
    entity_id: device_tracker.super_soco_tcmax_location
    state: not_home
action:
  - service: notify.mobile_app_brian_phone
    data:
      title: >-
        {{ state_attr("sensor.super_soco_tcmax_last_warning", "title") |
        capitalize }} 🏍
      message: "{{ state_attr(\"sensor.super_soco_tcmax_last_warning\", \"message\") }}"
      data:
        ttl: 0
        priority: high
mode: single

The important bits here are ttl and priority, otherwise Home Assistant's app will delay the notifications anywhere from minutes to waiting until you wake your phone.

The location condition is also helpful so it doesn't pester me with endless alerts while the bike is parked at home, but nothing to do with Android vs iPhone.

drakhart commented 3 months ago

And replying to the original question: I still need to reverse engineer (fancy words for peeping the code and API requests) the new Vmoto app to see if it really has any important difference with the "old" Vmoto Soco one, like different log in steps, target API, and so on.

Short answer: it could be compatible or not, I haven't checked yet. Honestly I'm getting a bit tired of these guys releasing new apps like there's no tomorrow.

darkner258 commented 3 months ago

It's hard to tell with this formatting as the indentation is difficult to spot, if you wrap your code with a line of triple back ticks (i.e. ```) it'll be easier to read, but if I'm right in assuming your mobile phone is not an iPhone, I expect that's the primary issue we need to sort here as Android uses a different set of options.

The HomeAssistant docs example gives this for iPhone:

- service: notify.mobile_app_<your_device_id_here>
  data:
    title: "Wake up!"
    message: "The house is on fire and the cat's stuck in the dryer!"
    data:
      push:
        sound:
          name: "default"
          critical: 1
          volume: 1.0

Whereas the same for Android looks like this:

- service: notify.mobile_app_<your_device_id_here>
  data:
    title: "Wake up!"
    message: "The house is on fire and the cat's stuck in the dryer!"
    data:
      ttl: 0
      priority: high

The docs also give a few additional interesting options for Android, such as an "alarm stream" that can make your phone vibrate or make noises or even speak words even when the phone is set to stay silent. https://companion.home-assistant.io/docs/notifications/critical-notifications/#:~:text=Critical%20alerts%20always%20appear%20at,notification%20rate%20limits%20as%20well.

Hope this comes in handy :)

Hey, so the code is below. My phone is iOS and I have run the notification part manually and it works. I have tried to set the alarm off on my bike but that did not trigger the notification :(

alias: Bike Alerts and Logging
description: Relay all bike alerts to Andy as critical.
trigger:
  - platform: state
    entity_id:
      - sensor.super_soco_tcmax_last_warning
condition: []
action:
  - service: logbook.log
    data:
      name: "{{ trigger.to_state.attributes.title }}"
      message: "{{ trigger.to_state.attributes.message }}"
      entity_id: sensor.super_soco_tcmax_last_warning
      domain: alert
  - choose:
      - conditions:
          - condition: template
            value_template: |-
              {{
                trigger.to_state.attributes.title == "burglar alarm"
                or
                trigger.to_state.attributes.title == "防盗报警"
              }}
        sequence:
          - service: notify.mobile_app_astra_zeneca_id_294xa1
            metadata: {}
            data:
              message: Bike has moved slightly
        alias: Alarm
      - conditions:
          - condition: template
            value_template: >-
              {{ trigger.to_state.attributes.title ==
              trigger.from_state.attributes.title }}
        sequence:
          - service: notify.mobile_app_astra_zeneca_id_294xa1
            metadata: {}
            data:
              data:
                push:
                  sound:
                    name: default
                    critical: 1
                    volume: 1
              message: Bike has moved
        alias: Other warnings that are different to last warning
mode: single
drakhart commented 3 months ago

Strange, that trigger should oh well, trigger the automation just fine.

Questions:

darkner258 commented 3 months ago

On Tue 28. 5. 2024 at 21:20, Brian Baidal @.***> wrote:

Strange, that trigger should oh well, trigger the automation just fine.

Questions:

  • Is your "Native Push Notifications" switch set to on? This is needed in order for the bike to send the alerts to Vmoto servers.
  • If you check that automation traces around the time it should've been triggered, what do you see? Just in case any of those conditions is preventing the actions to execute.

— Reply to this email directly, view it on GitHub https://github.com/drakhart/ha-super-soco-custom/issues/17#issuecomment-2135950208, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZKVEUKMMUV3WMYY5CXLYD3ZETKIVAVCNFSM6AAAAABICE3FMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZVHE2TAMRQHA . You are receiving this because you were mentioned.Message ID: @.***>

darkner258 commented 3 months ago

Hey there, so there's good news and bad news. The good news is that HA does recognize the alert. The bad one is that nothing happened afterwards. I've attached screenshots from the traces to help debugging along with my yaml. IMG_8369 IMG_8368 IMG_8367

darkner258 commented 3 months ago

But based on this, shouldn't the last condition be: `

apbarratt commented 3 months ago

Sorry guys, work and family life is most distracting right now! One thing I should have checked is that you've allowed Home Assistant to provide Critical Alerts. On your iPhone, open Settings->Home Assistant->Notifications and you should see a screen like this one. Notice that I've got Critical Alerts and Time-Sensitive Notifications turned on :) image I'm not sure if similar rules apply for Android.

I also don't know if Astra Zeneca might put restrictions on work devices, but hopefully not :) Just in case the assets number is considered sensitive information, you might want to edit your posts above to hide your work device ID too so you don't end up in your employer's information security team's bad books, especially with all the conspiracy nut jobs out there who might target AZ's excellent work!

darkner258 commented 3 months ago

Haha, the entity ID of my phone is purely random and meant as a joke :) I do get other critical notifications so this is not the problem either. I'll check it with the yaml updated as per my last message, if that makes sense

st 29. 5. 2024 v 11:57 odesílatel Andy Barratt @.***> napsal:

Sorry guys, work and family life is most distracting right now! One thing I should have checked is that you've allowed Home Assistant to provide Critical Alerts. On your iPhone, open Settings->Home Assistant->Notifications and you should see a screen like this one. Notice that I've got Critical Alerts and Time-Sensitive Notifications turned on :) image.png (view on web) https://github.com/drakhart/ha-super-soco-custom/assets/642320/d51a3c09-dd42-4dce-96b5-34396df16325 I'm not sure if similar rules apply for Android.

I also don't know if Astra Zeneca might put restrictions on work devices, but hopefully not :) Just in case the assets number is considered sensitive information, you might want to edit your posts above to hide your work device ID too so you don't end up in your employer's information security team's bad books, especially with all the conspiracy nut jobs out there who might target AZ's excellent work!

— Reply to this email directly, view it on GitHub https://github.com/drakhart/ha-super-soco-custom/issues/17#issuecomment-2137019246, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZKVEUPW3BPZ46PJZASN5ETZEWQ7JAVCNFSM6AAAAABICE3FMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZXGAYTSMRUGY . You are receiving this because you were mentioned.Message ID: @.***>

apbarratt commented 3 months ago

Ah fair enough, you got me 😅

This particular permission is for Home Assistant's critical alerts, so if you've not had other critical from HA it's still worth checking there specifically as I don't think Home Assistant is in the habit of requesting permission for critical notifications at onboarding time (though I may be mistaken about that!)

darkner258 commented 3 months ago

At last, it works! The last change in "to.state = illegal displacement" was the key :)

On Wed 29. 5. 2024 at 12:21, Andy Barratt @.***> wrote:

Ah fair enough, you got me 😅

This particular permission is for Home Assistant's critical alerts, so if you've not had other critical from HA it's still worth checking there specifically as I don't think Home Assistant is in the habit of requesting permission for critical notifications at onboarding time (though I may be mistaken about that!)

— Reply to this email directly, view it on GitHub https://github.com/drakhart/ha-super-soco-custom/issues/17#issuecomment-2137068292, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZKVEUJTSQVJVMRB377ORI3ZEWT23AVCNFSM6AAAAABICE3FMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZXGA3DQMRZGI . You are receiving this because you were mentioned.Message ID: @.***>

apbarratt commented 3 months ago

Ooo, I've never seen that particular one. I'm guessing that's one that appears when the bike is made to move when it's locked. I should probably update my own automation to make that one critical for me!

apbarratt commented 3 months ago

I must check actually, when I did that in the past the bike had a very annoying tendency to buck backwards and forwards, encouraging would be thieves to just drop it on the ground, I wonder if it still does it with my newer Vmoto ECU.

darkner258 commented 3 months ago

That's what comes out when the actual alarm is triggered :)

On Wed 29. 5. 2024 at 13:19, Andy Barratt @.***> wrote:

Ooo, I've never seen that particular one. I'm guessing that's one that appears when the bike is made to move when it's locked. I should probably update my own automation to make that one critical for me!

— Reply to this email directly, view it on GitHub https://github.com/drakhart/ha-super-soco-custom/issues/17#issuecomment-2137169157, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZKVEUJLQQSTU47WAP3U62DZEW2VHAVCNFSM6AAAAABICE3FMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZXGE3DSMJVG4 . You are receiving this because you were mentioned.Message ID: @.***>

apbarratt commented 3 months ago

Curious, I think when I've set mine off deliberately I've done it by pressing the power button whilst it's armed.

apbarratt commented 3 months ago

We really do need to find a way of collecting some data for all the different alerts and their translations. Partly so we can create better English translations, and partly so we can give @drakhart a proper Catalan translation, because I bet Vmoto are only giving him imperialist Spanish right now ;)

darkner258 commented 3 months ago

Yeah, I have done this by pressing the button with the bike locked. What I've noticed is that I have to let the alarm finish screaming to get the notification :) If i disarm it before that, no data is sent