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

Remove adapter.getMessage #575

Closed
Apollon77 opened this issue Dec 27, 2019 · 18 comments · Fixed by #1148
Closed

Remove adapter.getMessage #575

Apollon77 opened this issue Dec 27, 2019 · 18 comments · Fixed by #1148

Comments

@Apollon77
Copy link
Collaborator

... and fix the following Adapters before:

  • ...frankjoke mehrere
  • ioBroker.discovery
  • ioBroker.email ?
  • ioBroker.hmm
  • ioBroker.megad
  • ioBroker.megadd
  • ioBroker.megaesp
  • ioBroker.mqtt
  • ioBroker.node-red
  • ioBroker.noolite
  • ioBroker.opcua
  • ioBroker.owfs
  • ioBroker.ping
  • ioBroker.pushover ?
  • ioBroker.pushsafer
  • ioBroker.sayit
  • ioBroker.snips
  • ioBroker.telegram --> 1.4.7+
  • ioBroker.wrapper
  • ioBroker.zigbee
  • ioBroker.zont
  • iobroker.km200
@Apollon77 Apollon77 added this to Backlog in Next Version (3.0.x/3.1) Elena/Francesca via automation Dec 27, 2019
@Apollon77 Apollon77 moved this from Backlog to Planned in Next Version (3.0.x/3.1) Elena/Francesca Jan 6, 2020
@Apollon77
Copy link
Collaborator Author

Apollon77 commented Mar 12, 2020

Status 12.3.2020

Relevant:

  • sayit
  • snips
  • frankjoke (damit ggf radar2, systeminfo, broadlink2...)
  • pushsafer

Pot relevant:

  • hmm
  • megad
  • megadd
  • megaesp
  • wrapper

@foxriver76
Copy link
Collaborator

sayit has it removed now but 1.9.1 needs npm publish

@Apollon77
Copy link
Collaborator Author

Apollon77 commented Apr 3, 2020

Ok, updates Status (based on Github):

Left are:

  • hmm (not in Repo)
  • megad (70 installs, 5 weekly downloads)
  • megadd (75 installs, 5 weekly downloads)
  • megaesp (243 installs, 25 weekly downloads)
  • pushsafer (296 installs, 22 weekly downloads)
  • snips (211 installs, 10 weekly downloads)
  • frankjoke (damit ggf radar2, systeminfo, broadlink2...) PROBLEM! (together >3000 installs and such)
  • wrapper (not in repo)

@Apollon77
Copy link
Collaborator Author

Move deprecation to 3.1 in 6 months?

@foxriver76
Copy link
Collaborator

Yes. We should try to get access to frankjoe stuff in the meantime

@Apollon77
Copy link
Collaborator Author

I move that ticket to controller 3.1 to give us some ore time - I move after updating logging

@Apollon77 Apollon77 added this to Planned in Version 3.2.x (Grace) via automation Apr 6, 2020
@foxriver76
Copy link
Collaborator

AFAIK @frankjoke is active again. So any updates according to the list, so we can finally remove it in 3.2? ;-)

@frankjoke
Copy link

Ok, what's up? adapter.getMessage should not be used anymore? what is the migration strategy?

I use myAdapter for nearly all my adapters and this makes all the basic interface. I am requriting is and the test of new version is already in radar2 V2. It would be great to know what I need to change in addition.

@frankjoke
Copy link

@Apollon77
Ingo, I used already "@iobroker/adapter-core": "^2.4.0" but I am very unhappy with it. The reasoin is that you can't include it normally because if no ioBroker (js-controller) is available it kills the load of the adapter. This is not good because in testing and debugging I started the adapter in the past without ioBroker! Also test runs with Mocha and so on are not so easy to generate because you always need to run it from iobroker environment. Can you change this in future versions? It would amke our live testing and debugging adapter funktion much easier!

@foxriver76
Copy link
Collaborator

@frankjoke getMessage is doing absolutely nothing for some time now. So just remove it from your code - nothing to migrate ;-)

For the other question @AlCalzone is your man.

@AlCalzone
Copy link
Collaborator

AlCalzone commented Jun 12, 2020

@frankjoke Do you have an example of a test that is not working outside of the iobroker environment because of adapter-core?

For testing we have the @iobroker/testing module which has
a) Integration tests that don't need a complete ioBroker (but install a temporary js-controller)
b) Unit tests that mock out the entire iobroker part, but require some work on your part if you need to use iobroker methods.

@frankjoke
Copy link

@AlCalzone
Most of my adapters interface with some devices or services and in the past I used just VS-CODE on my development system to start/run the adapter from local directory with node with debug if I do not test iobroker-Topics. This is 90% of my testing and debugging because I need iobroker only for writing finaly states or adopting config.

All the devices where iobroker is running are remote and I need to copy changes to the node_modules... before starting a test on these machines with ioBroker.

Now by using the acore.Adapter class it crashes when loading outside of iobroker e´ven if I do not make an instance of it!
In testing I do not create instance of adapter, just use MyAdapter (my adapter wrapper) static functions to start main or do logs with console instead of iobroker.

@AlCalzone
Copy link
Collaborator

Can you link me to specific test code? I'm sure something can be done about your problem but I can't guess from vague explanations.

@frankjoke
Copy link

You can use my acceptdata adapter (generated with iobroker adaptertool) https://github.com/frankjoke/ioBroker.acceptdata
It will super seed some time my systeminfo adapter but at the moment ist just used to store my weather station data instead sending it to WeatherUnderground.
Even if you remove the new Acceptdata(); you cannot run any code if const utils = require("@iobroker/adapter-core"); is in the file because it dies not load completely ans states Cannot find js-controller.

before recent adapter-cores i could add test code before standard

// @ts-ignore parent is a valid property on module
if (module.parent) {
  // Export the constructor in compact mode
  /**
   * @param {Partial<ioBroker.AdapterOptions>} [options={}]
   */
  module.exports = (options) => new Acceptdata(options);
} else {
  // otherwise start the instance directly
 new Acceptdata();
}

and comment out the new Acceptdata(); and run the adapter even including iobroker adapter file.

@AlCalzone
Copy link
Collaborator

Ok, you basically need a way to use adapter-core "lazy" (only when its actually needed). So if you don't create an instance of the adapter (new ... commented out) or use any of the exported tools, it should not run.
Did I understand correctly?

and run the adapter even including iobroker adapter file

What do you mean by that? adapter.js is part of js-controller, so if you have that, adapter-core should find it.

@AlCalzone
Copy link
Collaborator

I've looked into this some more. What you need to do is structure your main file the old-fashioned way:
grafik
This allows you to move require("@iobroker/adapter-core") into the adapter initialization routine which you want to comment out for your tests. I've created frankjoke/ioBroker.acceptdata#1 to show you how.

@frankjoke
Copy link

@foxriver76 , Ok, I had it there because 3-4 years ago when I started to write adapters it was part of the 'eyample adapter' on which I built mine.

Will remove it from myAdapter and update adapters in next days.

@AlCalzone , You are right with your assumption in first post, will check your proposal to see if I can get it working.

@Apollon77 Apollon77 moved this from Planned to Backlog in Version 3.2.x (Grace) Dec 28, 2020
@foxriver76
Copy link
Collaborator

@Apollon77 could you run another grep?

foxriver76 added a commit to foxriver76/ioBroker.js-controller that referenced this issue Jan 3, 2021
Version 3.2.x (Grace) automation moved this from Backlog to Done Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

4 participants